Class: Foreman::TelemetrySinks::RailsLoggerSink

Inherits:
Object
  • Object
show all
Defined in:
lib/foreman/telemetry_sinks/rails_logger_sink.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ RailsLoggerSink

Returns a new instance of RailsLoggerSink.


3
4
5
6
# File 'lib/foreman/telemetry_sinks/rails_logger_sink.rb', line 3

def initialize(opts = {})
  @logger = Foreman::Logging.logger('telemetry')
  @level = Logger.const_get(opts[:level].try(:to_sym).try(:upcase) || :debug)
end

Instance Method Details

#add_counter(name, description, instance_labels) ⇒ Object


8
9
10
# File 'lib/foreman/telemetry_sinks/rails_logger_sink.rb', line 8

def add_counter(name, description, instance_labels)
  @logger.add(@level, "Registering counter #{name} labels #{instance_labels.inspect}")
end

#add_gauge(name, description, instance_labels) ⇒ Object


12
13
14
# File 'lib/foreman/telemetry_sinks/rails_logger_sink.rb', line 12

def add_gauge(name, description, instance_labels)
  @logger.add(@level, "Registering gauge #{name} labels #{instance_labels.inspect}")
end

#add_histogram(name, description, instance_labels, ignored) ⇒ Object


16
17
18
# File 'lib/foreman/telemetry_sinks/rails_logger_sink.rb', line 16

def add_histogram(name, description, instance_labels, ignored)
  @logger.add(@level, "Registering histogram #{name} labels #{instance_labels.inspect}")
end

#increment_counter(name, value, tags) ⇒ Object


20
21
22
# File 'lib/foreman/telemetry_sinks/rails_logger_sink.rb', line 20

def increment_counter(name, value, tags)
  @logger.add(@level, "Incrementing counter #{name} by #{sprintf('%0.02f', value)} #{tags.inspect}")
end

#observe_histogram(name, value, tags) ⇒ Object


28
29
30
# File 'lib/foreman/telemetry_sinks/rails_logger_sink.rb', line 28

def observe_histogram(name, value, tags)
  @logger.add(@level, "Observing histogram #{name} value #{sprintf('%0.02f', value)} #{tags.inspect}")
end

#set_gauge(name, value, tags) ⇒ Object


24
25
26
# File 'lib/foreman/telemetry_sinks/rails_logger_sink.rb', line 24

def set_gauge(name, value, tags)
  @logger.add(@level, "Setting gauge #{name} to #{sprintf('%0.02f', value)} #{tags.inspect}")
end