Class AbstractDropwizardExports<R,F,C,G,H,T,M,B,S>
java.lang.Object
io.prometheus.metrics.instrumentation.dropwizard5.internal.AbstractDropwizardExports<R,F,C,G,H,T,M,B,S>
- Type Parameters:
R- The Dropwizard MetricRegistry typeF- The Dropwizard MetricFilter typeC- The Dropwizard Counter typeG- The Dropwizard Gauge typeH- The Dropwizard Histogram typeT- The Dropwizard Timer typeM- The Dropwizard Meter typeB- The Dropwizard Metric base typeS- The Dropwizard Snapshot type
- All Implemented Interfaces:
io.prometheus.metrics.model.registry.MultiCollector
- Direct Known Subclasses:
DropwizardExports
public abstract class AbstractDropwizardExports<R,F,C,G,H,T,M,B,S>
extends Object
implements io.prometheus.metrics.model.registry.MultiCollector
Abstract base class for Dropwizard metrics exporters. Contains all the common logic for
converting Dropwizard metrics to Prometheus metrics. Subclasses only need to implement
collectMetricSnapshots() to handle version-specific registry APIs.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final InvalidMetricHandlerprotected final CustomLabelMapperprotected final Fprotected final R -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractDropwizardExports(R registry, F metricFilter, CustomLabelMapper labelMapper, InvalidMetricHandler invalidMetricHandler) -
Method Summary
Modifier and TypeMethodDescriptionio.prometheus.metrics.model.snapshots.MetricSnapshotscollect()protected <K,V> void collectMetricKind(io.prometheus.metrics.model.snapshots.MetricSnapshots.Builder builder, Map<K, V> metrics, BiFunction<String, V, io.prometheus.metrics.model.snapshots.MetricSnapshot> toSnapshot, Function<K, String> keyExtractor) protected abstract io.prometheus.metrics.model.snapshots.MetricSnapshotsCollect all metric snapshots from the registry.protected io.prometheus.metrics.model.snapshots.MetricSnapshotfromCounter(String dropwizardName, C counter) Export counter as Prometheus Gauge.protected io.prometheus.metrics.model.snapshots.MetricSnapshotExport gauge as a prometheus gauge.protected io.prometheus.metrics.model.snapshots.MetricSnapshotfromHistogram(String dropwizardName, H histogram) Convert histogram snapshot.protected io.prometheus.metrics.model.snapshots.MetricSnapshotExport a Meter as a prometheus COUNTER.protected io.prometheus.metrics.model.snapshots.MetricSnapshotfromSnapshotAndCount(String dropwizardName, S snapshot, long count, double factor, String helpMessage) Export a histogram snapshot as a prometheus SUMMARY.protected io.prometheus.metrics.model.snapshots.MetricSnapshotExport Dropwizard Timer as a histogram.protected abstract doubleget75thPercentile(S snapshot) protected abstract doubleget95thPercentile(S snapshot) protected abstract doubleget98thPercentile(S snapshot) protected abstract doubleget999thPercentile(S snapshot) protected abstract doubleget99thPercentile(S snapshot) protected abstract longgetCounterCount(C counter) protected abstract ObjectgetGaugeValue(G gauge) protected static StringgetHelpMessage(String metricName, Object metric) protected abstract longgetHistogramCount(H histogram) protected abstract SgetHistogramSnapshot(H histogram) protected abstract doubleprotected abstract longgetMeterCount(M meter) protected io.prometheus.metrics.model.snapshots.MetricMetadatagetMetricMetaData(String metricName, B metric) protected abstract longgetTimerCount(T timer) protected abstract SgetTimerSnapshot(T timer) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.prometheus.metrics.model.registry.MultiCollector
collect, collect, collect, getLabelNames, getMetadata, getMetricType, getPrometheusNames
-
Field Details
-
registry
-
metricFilter
-
labelMapper
-
invalidMetricHandler
-
-
Constructor Details
-
AbstractDropwizardExports
protected AbstractDropwizardExports(R registry, F metricFilter, @Nullable CustomLabelMapper labelMapper, InvalidMetricHandler invalidMetricHandler)
-
-
Method Details
-
getHelpMessage
-
getMetricMetaData
-
fromCounter
protected io.prometheus.metrics.model.snapshots.MetricSnapshot fromCounter(String dropwizardName, C counter) Export counter as Prometheus Gauge. -
fromGauge
@Nullable protected io.prometheus.metrics.model.snapshots.MetricSnapshot fromGauge(String dropwizardName, G gauge) Export gauge as a prometheus gauge. -
fromSnapshotAndCount
protected io.prometheus.metrics.model.snapshots.MetricSnapshot fromSnapshotAndCount(String dropwizardName, S snapshot, long count, double factor, String helpMessage) Export a histogram snapshot as a prometheus SUMMARY.- Parameters:
dropwizardName- metric name.snapshot- the histogram snapshot.count- the total sample count for this snapshot.factor- a factor to apply to histogram values.
-
fromHistogram
protected io.prometheus.metrics.model.snapshots.MetricSnapshot fromHistogram(String dropwizardName, H histogram) Convert histogram snapshot. -
fromTimer
protected io.prometheus.metrics.model.snapshots.MetricSnapshot fromTimer(String dropwizardName, T timer) Export Dropwizard Timer as a histogram. Use TIME_UNIT as time unit. -
fromMeter
protected io.prometheus.metrics.model.snapshots.MetricSnapshot fromMeter(String dropwizardName, M meter) Export a Meter as a prometheus COUNTER. -
collect
public io.prometheus.metrics.model.snapshots.MetricSnapshots collect()- Specified by:
collectin interfaceio.prometheus.metrics.model.registry.MultiCollector
-
collectMetricKind
protected <K,V> void collectMetricKind(io.prometheus.metrics.model.snapshots.MetricSnapshots.Builder builder, Map<K, V> metrics, BiFunction<String, V, io.prometheus.metrics.model.snapshots.MetricSnapshot> toSnapshot, Function<K, String> keyExtractor) -
collectMetricSnapshots
protected abstract io.prometheus.metrics.model.snapshots.MetricSnapshots collectMetricSnapshots()Collect all metric snapshots from the registry. -
getCounterCount
-
getGaugeValue
-
getHistogramSnapshot
-
getHistogramCount
-
getTimerSnapshot
-
getTimerCount
-
getMeterCount
-
getMedian
-
get75thPercentile
-
get95thPercentile
-
get98thPercentile
-
get99thPercentile
-
get999thPercentile
-