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 type
F - The Dropwizard MetricFilter type
C - The Dropwizard Counter type
G - The Dropwizard Gauge type
H - The Dropwizard Histogram type
T - The Dropwizard Timer type
M - The Dropwizard Meter type
B - The Dropwizard Metric base type
S - 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 Details

  • Constructor Details

  • Method Details

    • getHelpMessage

      protected static String getHelpMessage(String metricName, Object metric)
    • getMetricMetaData

      protected io.prometheus.metrics.model.snapshots.MetricMetadata getMetricMetaData(String metricName, B metric)
    • 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:
      collect in interface io.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

      protected abstract long getCounterCount(C counter)
    • getGaugeValue

      protected abstract Object getGaugeValue(G gauge)
    • getHistogramSnapshot

      protected abstract S getHistogramSnapshot(H histogram)
    • getHistogramCount

      protected abstract long getHistogramCount(H histogram)
    • getTimerSnapshot

      protected abstract S getTimerSnapshot(T timer)
    • getTimerCount

      protected abstract long getTimerCount(T timer)
    • getMeterCount

      protected abstract long getMeterCount(M meter)
    • getMedian

      protected abstract double getMedian(S snapshot)
    • get75thPercentile

      protected abstract double get75thPercentile(S snapshot)
    • get95thPercentile

      protected abstract double get95thPercentile(S snapshot)
    • get98thPercentile

      protected abstract double get98thPercentile(S snapshot)
    • get99thPercentile

      protected abstract double get99thPercentile(S snapshot)
    • get999thPercentile

      protected abstract double get999thPercentile(S snapshot)