class Datadog::Metrics::Logging::Adapter
Surrogate for Datadog::Statsd to log elsewhere
Attributes
logger[RW]
Public Class Methods
new(logger = nil)
click to toggle source
# File lib/ddtrace/metrics.rb, line 188 def initialize(logger = nil) @logger = logger || Logger.new(STDOUT).tap do |l| l.level = Logger::INFO l.progname = nil l.formatter = proc do |_severity, datetime, _progname, msg| stat = JSON.parse(msg[3..-1]) # Trim off leading progname... "#{JSON.dump(timestamp: datetime.to_i, message: 'Metric sent.', metric: stat)}\n" end end end
Public Instance Methods
count(stat, value, options = nil)
click to toggle source
# File lib/ddtrace/metrics.rb, line 199 def count(stat, value, options = nil) logger.info({ stat: stat, type: :count, value: value, options: options }.to_json) end
distribution(stat, value, options = nil)
click to toggle source
# File lib/ddtrace/metrics.rb, line 203 def distribution(stat, value, options = nil) logger.info({ stat: stat, type: :distribution, value: value, options: options }.to_json) end
gauge(stat, value, options = nil)
click to toggle source
# File lib/ddtrace/metrics.rb, line 211 def gauge(stat, value, options = nil) logger.info({ stat: stat, type: :gauge, value: value, options: options }.to_json) end
increment(stat, options = nil)
click to toggle source
# File lib/ddtrace/metrics.rb, line 207 def increment(stat, options = nil) logger.info({ stat: stat, type: :increment, options: options }.to_json) end