Class: Monitoring::OpenCensusCounter
- Inherits:
-
BaseCounter
- Object
- BaseCounter
- Monitoring::OpenCensusCounter
- Defined in:
- lib/fluent/plugin/monitoring.rb
Overview
OpenCensus implementation of counters.
Instance Method Summary collapse
- #increment(by: 1, labels: {}) ⇒ Object
-
#initialize(recorder, measure, translator) ⇒ OpenCensusCounter
constructor
A new instance of OpenCensusCounter.
Constructor Details
#initialize(recorder, measure, translator) ⇒ OpenCensusCounter
Returns a new instance of OpenCensusCounter.
37 38 39 40 41 42 43 44 |
# File 'lib/fluent/plugin/monitoring.rb', line 37 def initialize(recorder, measure, translator) super() raise ArgumentError, 'measure must not be nil' if measure.nil? @recorder = recorder @measure = measure @translator = translator end |
Instance Method Details
#increment(by: 1, labels: {}) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/fluent/plugin/monitoring.rb', line 46 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 |