Class ReplaceableCollectorRegistry

java.lang.Object
io.prometheus.client.CollectorRegistry
org.graylog.metrics.prometheus.ReplaceableCollectorRegistry

public class ReplaceableCollectorRegistry extends io.prometheus.client.CollectorRegistry
Custom CollectorRegistry that delegates all read operations to a registry reference. This allows atomic collector registry replacements at runtime. The standard CollectorRegistry only supports a register/unregister workflow which opens up a potential race condition. And since the HTTPServer doesn't allow the replacement of the collector registry without restarting the HTTP server, we need this custom implementation. Write operations are not supported and will throw an UnsupportedOperationException.
  • Constructor Details

    • ReplaceableCollectorRegistry

      public ReplaceableCollectorRegistry(AtomicReference<io.prometheus.client.CollectorRegistry> registryRef)
  • Method Details

    • register

      public void register(io.prometheus.client.Collector m)
      Overrides:
      register in class io.prometheus.client.CollectorRegistry
    • unregister

      public void unregister(io.prometheus.client.Collector m)
      Overrides:
      unregister in class io.prometheus.client.CollectorRegistry
    • clear

      public void clear()
      Overrides:
      clear in class io.prometheus.client.CollectorRegistry
    • metricFamilySamples

      public Enumeration<io.prometheus.client.Collector.MetricFamilySamples> metricFamilySamples()
      Overrides:
      metricFamilySamples in class io.prometheus.client.CollectorRegistry
    • filteredMetricFamilySamples

      public Enumeration<io.prometheus.client.Collector.MetricFamilySamples> filteredMetricFamilySamples(Set<String> includedNames)
      Overrides:
      filteredMetricFamilySamples in class io.prometheus.client.CollectorRegistry
    • getSampleValue

      public Double getSampleValue(String name)
      Overrides:
      getSampleValue in class io.prometheus.client.CollectorRegistry
    • getSampleValue

      public Double getSampleValue(String name, String[] labelNames, String[] labelValues)
      Overrides:
      getSampleValue in class io.prometheus.client.CollectorRegistry