class Monitoring::OpenCensusCounter
OpenCensus implementation of counters.
Public Class Methods
new(recorder, measure, translator)
click to toggle source
# File lib/fluent/plugin/monitoring.rb, line 35 def initialize(recorder, measure, translator) raise ArgumentError, 'measure must not be nil' if measure.nil? @recorder = recorder @measure = measure @translator = translator end
Public Instance Methods
increment(by: 1, labels: {})
click to toggle source
# File lib/fluent/plugin/monitoring.rb, line 42 def increment(by: 1, labels: {}) labels = @translator.translate_labels(labels) tag_map = OpenCensus::Tags::TagMap.new( labels.map { |k, v| [k.to_s, v.to_s] }.to_h) @recorder.record(@measure.create_measurement(value: by, tags: tag_map)) end