Sha256: 3147bfdb5a3bd1d86524e6eeef634f0812f42397b49e843918875ce93bba74ed

Contents?: true

Size: 619 Bytes

Versions: 33

Compression:

Stored size: 619 Bytes

Contents

class MyCustomCollector < PrometheusExporter::Server::Collector
  def initialize
    @gauge1 = PrometheusExporter::Metric::Gauge.new("thing1", "I am thing 1")
    @gauge2 = PrometheusExporter::Metric::Gauge.new("thing2", "I am thing 2")
    @mutex = Mutex.new
  end

  def process(obj)
    @mutex.synchronize do
      if thing1 = obj["thing1"]
        @gauge1.observe(thing1)
      end

      if thing2 = obj["thing2"]
        @gauge2.observe(thing2)
      end
    end
  end

  def prometheus_metrics_text
    @mutex.synchronize do
      "#{@gauge1.to_prometheus_text}\n#{@gauge2.to_prometheus_text}"
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
prometheus_exporter-0.1.12 examples/custom_collector.rb
prometheus_exporter-0.1.11 examples/custom_collector.rb
prometheus_exporter-0.1.10 examples/custom_collector.rb
prometheus_exporter-0.1.9 examples/custom_collector.rb
prometheus_exporter-0.1.8 examples/custom_collector.rb
prometheus_exporter-0.1.7 examples/custom_collector.rb
prometheus_exporter-0.1.6 examples/custom_collector.rb
prometheus_exporter-0.1.5 examples/custom_collector.rb
prometheus_exporter-0.1.4 examples/custom_collector.rb
prometheus_exporter-0.1.3 examples/custom_collector.rb
prometheus_exporter-0.1.2 examples/custom_collector.rb
prometheus_exporter-0.1.1 examples/custom_collector.rb
prometheus_exporter-0.1.0 examples/custom_collector.rb