module Metrics

Public Class Methods

configuration() click to toggle source
# File lib/metrics.rb, line 81
def configuration
  @configuration ||= Configuration.new
end
configure() { |configuration| ... } click to toggle source
# File lib/metrics.rb, line 85
def configure
  yield configuration
end
group(namespace = nil, options = {}, &block) click to toggle source

Public: Group multiple instruments.

Example

Metrics.group 'sidekiq' do |group|
  group.instrument 'request.time' do
    begin
      @app.call(env)
    rescue Exception => e
      instrument 'exceptions', 1
      raise
    end
  end
end

Returns nothing.

# File lib/metrics.rb, line 72
def group(namespace = nil, options = {}, &block)
  instrumenters = Grouping.instrument(namespace, &block)
  Handler.handle(*instrumenters)
end
instrument(*args, &block) click to toggle source

Public: Instrument a metric.

Example

# Instrument the duration of an event.
Metrics.instrument 'rack.request' do
  @app.call(env)
end

# Instrument a specific value.
Metrics.instrument 'workers.busy', 10, units: 'workers'

# Instrument something with a specific source.
Metrics.instrument 'sidekiq.queue', source: 'background' do
  yield
end

Returns the return value of the block.

# File lib/metrics.rb, line 52
def instrument(*args, &block)
  Handler.handle(Instrumenter.instrument(*args, &block))
end
subscribe() click to toggle source
# File lib/metrics.rb, line 77
def subscribe
  $stderr.puts "Metrics#subscribe is deprecated and will be removed in 1.0."
end