Class: Fluent::Plugin::CMetricsMetrics
- Inherits:
-
Metrics
- Object
- Metrics
- Fluent::Plugin::CMetricsMetrics
- Defined in:
- lib/fluent/plugin/metrics_cmetrics.rb
Instance Attribute Summary collapse
-
#_subsystem ⇒ Object
readonly
_subsystem for testing.
-
#cmetrics ⇒ Object
readonly
_subsystem for testing.
Instance Method Summary collapse
- #add(value) ⇒ Object
- #calyptia_metrics_subsystem_mapper(subsystem) ⇒ Object
- #configure(conf) ⇒ Object
- #create(namespace:, subsystem:, name:, help_text:, labels: {}) ⇒ Object
- #dec_gauge ⇒ Object
- #get ⇒ Object
- #inc ⇒ Object
-
#initialize ⇒ CMetricsMetrics
constructor
A new instance of CMetricsMetrics.
- #multi_workers_ready? ⇒ Boolean
- #set(value) ⇒ Object
- #sub_gauge(value) ⇒ Object
Constructor Details
#initialize ⇒ CMetricsMetrics
Returns a new instance of CMetricsMetrics.
30 31 32 33 34 35 36 |
# File 'lib/fluent/plugin/metrics_cmetrics.rb', line 30 def initialize super @cmetrics = nil @default_labels_keys = [] @default_labels_values = [] @_subsystem = nil end |
Instance Attribute Details
#_subsystem ⇒ Object (readonly)
_subsystem for testing.
26 27 28 |
# File 'lib/fluent/plugin/metrics_cmetrics.rb', line 26 def _subsystem @_subsystem end |
#cmetrics ⇒ Object (readonly)
_subsystem for testing.
26 27 28 |
# File 'lib/fluent/plugin/metrics_cmetrics.rb', line 26 def cmetrics @cmetrics end |
Instance Method Details
#add(value) ⇒ Object
104 105 106 |
# File 'lib/fluent/plugin/metrics_cmetrics.rb', line 104 def add(value) @cmetrics.add(value, @labels_values) end |
#calyptia_metrics_subsystem_mapper(subsystem) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/fluent/plugin/metrics_cmetrics.rb', line 78 def calyptia_metrics_subsystem_mapper(subsystem) case subsystem.to_s when "buffer" # Calyptia's service should handle buffer metrics as storage. subsystem = "storage" end @_subsystem = subsystem subsystem end |
#configure(conf) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fluent/plugin/metrics_cmetrics.rb', line 38 def configure(conf) super default_labels.each do |key, value| @default_labels_keys << key @default_labels_values << value end # Handle label(s) within <system> directive as default label(s) unless labels.empty? labels.each do |key, value| @default_labels_keys << key @default_labels_values << value end end @labels_keys = @default_labels_keys @labels_values = @default_labels_values if use_gauge_metric @cmetrics = ::CMetrics::Gauge.new class << self alias_method :dec, :dec_gauge alias_method :sub, :sub_gauge end else @cmetrics = ::CMetrics::Counter.new end end |
#create(namespace:, subsystem:, name:, help_text:, labels: {}) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fluent/plugin/metrics_cmetrics.rb', line 65 def create(namespace:, subsystem:, name:, help_text:, labels: {}) if @enable_calyptia_metrics_mapping subsystem = calyptia_metrics_subsystem_mapper(subsystem) end @cmetrics.create(namespace, subsystem, name, help_text, @labels_keys) # Add specified in #create label(s) as static label(s). unless labels.empty? labels.each do |k,v| @cmetrics.add_label(k, v) end end end |
#dec_gauge ⇒ Object
100 101 102 |
# File 'lib/fluent/plugin/metrics_cmetrics.rb', line 100 def dec_gauge @cmetrics.dec(@labels_values) end |
#get ⇒ Object
92 93 94 |
# File 'lib/fluent/plugin/metrics_cmetrics.rb', line 92 def get @cmetrics.val(@labels_values) end |
#inc ⇒ Object
96 97 98 |
# File 'lib/fluent/plugin/metrics_cmetrics.rb', line 96 def inc @cmetrics.inc(@labels_values) end |
#multi_workers_ready? ⇒ Boolean
88 89 90 |
# File 'lib/fluent/plugin/metrics_cmetrics.rb', line 88 def multi_workers_ready? true end |
#set(value) ⇒ Object
112 113 114 |
# File 'lib/fluent/plugin/metrics_cmetrics.rb', line 112 def set(value) @cmetrics.set(value, @labels_values) end |
#sub_gauge(value) ⇒ Object
108 109 110 |
# File 'lib/fluent/plugin/metrics_cmetrics.rb', line 108 def sub_gauge(value) @cmetrics.sub(value, @labels_values) end |