Class GlobalLabelSampleBuilderDecorator

java.lang.Object
com.expediagroup.dropwizard.prometheus.GlobalLabelSampleBuilderDecorator
All Implemented Interfaces:
io.prometheus.client.dropwizard.samplebuilder.SampleBuilder

public class GlobalLabelSampleBuilderDecorator extends Object implements io.prometheus.client.dropwizard.samplebuilder.SampleBuilder
In prometheus land this is an anti-pattern. Ideally global labels should come from the prometheus server which can be setup to re-label or enrich at scrapping time. It is considered an anti-pattern to use the client side to enrich or add fixed labels.. That said with the advent of open metrics it is not always prometheus that scrapes and there are certain times where the values need to come from the client. Dropwizard makes this particulary hard because there are no labels to begin with, the custom mapping namer can fix some of this but that one just assumes that the values come from the actual metric name. This class just adds fixed tags to every sample.
  • Constructor Details

    • GlobalLabelSampleBuilderDecorator

      public GlobalLabelSampleBuilderDecorator(io.prometheus.client.dropwizard.samplebuilder.SampleBuilder decorate, Map<String,String> labels)
  • Method Details

    • createSample

      public io.prometheus.client.Collector.MetricFamilySamples.Sample createSample(String dropwizardName, String nameSuffix, List<String> additionalLabelNames, List<String> additionalLabelValues, double value)
      Specified by:
      createSample in interface io.prometheus.client.dropwizard.samplebuilder.SampleBuilder