Module: SSO::Meter

Includes:
Logging
Included in:
Benchmarking, Client::Warden::Hooks::AfterFetch
Defined in:
lib/sso/meter.rb

Instance Method Summary collapse

Methods included from Logging

#debug, #error, #fatal, #info, #logger, #progname, #warn

Instance Method Details

#caller_nameObject



23
24
25
# File 'lib/sso/meter.rb', line 23

def caller_name
  self.class.name
end

#metricObject



27
28
29
# File 'lib/sso/meter.rb', line 27

def metric
  ::SSO.config.metric
end

#timing(key:, value:, tags: nil, data: {}) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/sso/meter.rb', line 14

def timing(key:, value:, tags: nil, data: {})
  data[:caller] = caller_name
  debug { "Measuring timing #{key.inspect} with value #{value.inspect} and tags #{tags.inspect} and data #{data.inspect}" }
  metric.call type: :timing, key: "sso.#{key}", value: value, tags: tags, data: data

rescue => exception
  ::SSO.config.exception_handler.call exception
end

#track(key:, value: 1, tags: nil, data: {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/sso/meter.rb', line 5

def track(key:, value: 1, tags: nil, data: {})
  data[:caller] = caller_name
  debug { "Measuring increment #{key.inspect} with value #{value.inspect} and tags #{tags.inspect} and data #{data.inspect}" }
  metric.call type: :increment, key: "sso.#{key}", value: value, tags: tags, data: data

rescue => exception
  ::SSO.config.exception_handler.call exception
end