Class: Temporal::Metrics

Inherits:
Object
  • Object
show all
Defined in:
lib/temporal/metrics.rb

Instance Method Summary collapse

Constructor Details

#initialize(adapter) ⇒ Metrics

Returns a new instance of Metrics.



3
4
5
# File 'lib/temporal/metrics.rb', line 3

def initialize(adapter)
  @adapter = adapter
end

Instance Method Details

#count(key, count, tags = {}) ⇒ Object



15
16
17
18
19
# File 'lib/temporal/metrics.rb', line 15

def count(key, count, tags = {})
  adapter.count(key, count, tags)
rescue StandardError => error
  Temporal.logger.error("Adapter failed to send count metrics for #{key}: #{error.inspect}")
end

#decrement(key, tags = {}) ⇒ Object



11
12
13
# File 'lib/temporal/metrics.rb', line 11

def decrement(key, tags = {})
  count(key, -1, tags)
end

#gauge(key, value, tags = {}) ⇒ Object



21
22
23
24
25
# File 'lib/temporal/metrics.rb', line 21

def gauge(key, value, tags = {})
  adapter.gauge(key, value, tags)
rescue StandardError => error
  Temporal.logger.error("Adapter failed to send gauge metrics for #{key}: #{error.inspect}")
end

#increment(key, tags = {}) ⇒ Object



7
8
9
# File 'lib/temporal/metrics.rb', line 7

def increment(key, tags = {})
  count(key, 1, tags)
end

#timing(key, time, tags = {}) ⇒ Object



27
28
29
30
31
# File 'lib/temporal/metrics.rb', line 27

def timing(key, time, tags = {})
  adapter.timing(key, time, tags)
rescue StandardError => error
  Temporal.logger.error("Adapter failed to send timing metrics for #{key}: #{error.inspect}")
end