com.signalfx.codahale.reporter.MetricMetadata Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of signalfx-codahale Show documentation
Show all versions of signalfx-codahale Show documentation
Dropwizard Codahale metrics plugin for signalfx
The newest version!
package com.signalfx.codahale.reporter;
import java.util.Map;
import com.codahale.metrics.Metric;
import com.codahale.metrics.MetricRegistry;
import com.signalfx.shaded.google.common.base.Optional;
import com.signalfx.codahale.metrics.MetricBuilder;
import com.signalfx.metrics.protobuf.SignalFxProtocolBuffers;
/**
* Allows users to modify a metric with different source or metric parts than the default we pick
* from codahale. Note: This class must be thread safe.
*/
public interface MetricMetadata {
public static final String SOURCE = "source";
public static final String METRIC = "metric";
public Map getTags(Metric metric);
public Optional getMetricType(Metric metric);
/**
* Create an object to tag a metric with data. Registering two different metrics with the same
* metadata will result in an exception. In that case, use {@link #forBuilder(com.signalfx.codahale.metrics.MetricBuilder)}
* @param metric The metric will tag.
* @param The type of metric. It is implied by the metric type.
* @return An object to tag the given metric.
*/
public Tagger forMetric(M metric);
@Deprecated
public Tagger tagMetric(M metric);
/**
* Create a tagger for a type of objects. This is different than {@link #forMetric(com.codahale.metrics.Metric)}
* because it will not use the builder to create a metric unless if it already exists.
* @param metricBuilder The builder that creates metrics.
* @param The type of metric to create.
* @return An object to tag metrics.
*/
public BuilderTagger forBuilder(MetricBuilder metricBuilder);
/**
* Removes the specified metric from the metric metadata and registry.
* @param metric The metric to remove, cannot be null.
* @param metricRegistry Registry to remove the metric from
* @return True if the metric was found and removed, false otherwise
*/
public boolean removeMetric(M metric, MetricRegistry metricRegistry);
public interface TaggerBase> {
/**
* Tag the metric with a sf_source
* @param sourceName Source name for the sf_source
* @return this
* @deprecated The use of the build in source parameter is deprecated and discouraged. Use
* {@link #withDimension(String, String)} instead.
*/
@Deprecated
T withSourceName(String sourceName);
/**
* Changes the metric name of this metric from the default (which is the codahale metric
* name), to another string
* @param metricName The new name in SignalFx of this metric
* @return this
*/
T withMetricName(String metricName);
/**
* Adds a dimension to this metric
* @param key The dimension key to add
* @param value The dimensino value to add
* @return this
*/
T withDimension(String key, String value);
/**
* Changes the default metric type of this metric to the SignalFx metric type passed in
* @param metricType The new metric type of this metric
* @return this
*/
T withMetricType(SignalFxProtocolBuffers.MetricType metricType);
}
public interface Tagger extends TaggerBase> {
/**
* Helper that registers a metric in the registry, throwing an exception if it already
* exists.
* @param metricRegistry Where to register the metric.
* @return The new metric
*/
M register(MetricRegistry metricRegistry);
/**
* Returns the tagged metric
* @return the tagged metric
*/
M metric();
}
public interface BuilderTagger extends TaggerBase> {
/**
* Create this metric in the registry, or return the currently registered metric if it
* already exists.
* @param metricRegistry Registry to create the metric in
* @return The new (or existing) metric.
*/
M createOrGet(MetricRegistry metricRegistry);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy