Class: Nightwing::Metric

Inherits:
Object
  • Object
show all
Defined in:
lib/nightwing/metric.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace) ⇒ Metric

Returns a new instance of Metric.



7
8
9
# File 'lib/nightwing/metric.rb', line 7

def initialize(namespace)
  @namespace = namespace
end

Instance Attribute Details

#namespaceObject (readonly)

Returns the value of attribute namespace.



5
6
7
# File 'lib/nightwing/metric.rb', line 5

def namespace
  @namespace
end

Instance Method Details

#for(queue:, worker: nil) ⇒ Object

Generates a metric name

returns a String object

Parameters:

  • queue (String)
  • worker (Class) (defaults to: nil)


18
19
20
21
# File 'lib/nightwing/metric.rb', line 18

def for(queue:, worker: nil)
  worker_name = worker.to_s.underscore.tr("/", "_") if worker
  [namespace, queue, worker_name].compact.join(".")
end