Class: Dynflow::Telemetry

Inherits:
Object
  • Object
show all
Defined in:
lib/dynflow/telemetry.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.instanceObject (readonly)

Returns the value of attribute instance.



9
10
11
# File 'lib/dynflow/telemetry.rb', line 9

def instance
  @instance
end

Class Method Details

.measure(name, tags = {}, &block) ⇒ Object



24
25
26
# File 'lib/dynflow/telemetry.rb', line 24

def measure(name, tags = {}, &block)
  @instance.measure name, tags, &block
end

.register_metrics!void

This method returns an undefined value.

Registers the metrics to be collected



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/dynflow/telemetry.rb', line 30

def register_metrics!
  return if @registered
  @registered = true
  with_instance do |t|
    # Worker related
    t.add_gauge   :dynflow_active_workers, 'The number of currently busy workers',
                  [:queue, :world]
    t.add_counter :dynflow_worker_events, 'The number of processed events',
                  [:queue, :world, :worker]

    # Execution plan related
    t.add_gauge   :dynflow_active_execution_plans, 'The number of active execution plans',
                  [:action, :world, :state]
    t.add_gauge   :dynflow_queue_size, 'Number of items in queue',
                  [:queue, :world]
    t.add_counter :dynflow_finished_execution_plans, 'The number of execution plans',
                  [:action, :world, :result]

    # Step related
    # TODO: Configure buckets in a sane manner
    t.add_histogram :dynflow_step_real_time, 'The time between the start end end of the step',
                    [:action, :phase]
    t.add_histogram :dynflow_step_execution_time, 'The time spent executing a step',
                    [:action, :phase]

    # Connector related
    t.add_counter :dynflow_connector_envelopes, 'The number of envelopes handled by a connector',
                  [:world, :direction]

    # Persistence related
    t.add_histogram :dynflow_persistence, 'The time spent communicating with the database',
                    [:world, :method]
  end
end

.set_adapter(adapter) ⇒ Object

Configures the adapter to use for telemetry

Parameters:



14
15
16
# File 'lib/dynflow/telemetry.rb', line 14

def set_adapter(adapter)
  @instance = adapter
end

.with_instance(&block) ⇒ Object

Passes the block into the current telemetry adapter’s Dynflow::TelemetryAdapters::Abstract#with_instance method



20
21
22
# File 'lib/dynflow/telemetry.rb', line 20

def with_instance(&block)
  @instance.with_instance &block
end