Class: Dynflow::TelemetryAdapters::Abstract

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

Direct Known Subclasses

Dummy, StatsD

Constant Summary collapse

DEFAULT_BUCKETS =

Default buckets to use when defining a histogram

[0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 20, 30, 60, 120, 300, 600, 1200].freeze

Instance Method Summary collapse

Instance Method Details

#add_counter(name, description, instance_labels = []) ⇒ void

This method returns an undefined value.

Configures a counter to be collected

Parameters:

  • name (String)

    Name of the counter

  • description (String)

    Human-readable description of the counter

  • instance_labels (Array<String>) (defaults to: [])

    Labels which will be assigned to the collected data



15
16
# File 'lib/dynflow/telemetry_adapters/abstract.rb', line 15

def add_counter(name, description, instance_labels = [])
end

#add_gauge(name, description, instance_labels = []) ⇒ void

This method returns an undefined value.

Configures a gauge to be collected

Parameters:

  • name (String)

    Name of the gauge

  • description (String)

    Human-readable description of the gauge

  • instance_labels (Array<String>) (defaults to: [])

    Labels which will be assigned to the collected data



24
25
# File 'lib/dynflow/telemetry_adapters/abstract.rb', line 24

def add_gauge(name, description, instance_labels = [])
end

#add_histogram(name, description, instance_labels = [], buckets = DEFAULT_BUCKETS) ⇒ void

This method returns an undefined value.

Configures a histogram to be collected

Parameters:

  • name (String)

    Name of the histogram

  • description (String)

    Human-readable description of the histogram

  • instance_labels (Array<String>) (defaults to: [])

    Labels which will be assigned to the collected data

  • buckest (Array<Integer>)

    Buckets to fit the value into



34
35
# File 'lib/dynflow/telemetry_adapters/abstract.rb', line 34

def add_histogram(name, description, instance_labels = [], buckets = DEFAULT_BUCKETS)
end

#increment_counter(name, value = 1, tags = {}) ⇒ void

This method returns an undefined value.

Increments a counter

Parameters:

  • name (String, Symbol)

    Name of the counter to increment

  • value (Integer) (defaults to: 1)

    Step to increment by

  • tags (Hash{Symbol=>String}) (defaults to: {})

    Tags to apply to this record



43
44
# File 'lib/dynflow/telemetry_adapters/abstract.rb', line 43

def increment_counter(name, value = 1, tags = {})
end

#measure(name, tags = {}) ⇒ Object



72
73
74
75
76
77
78
79
# File 'lib/dynflow/telemetry_adapters/abstract.rb', line 72

def measure(name, tags = {})
  before = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  yield
ensure
  after = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  duration = (after - before) * 1000 # In miliseconds
  observe_histogram(name, duration, tags)
end

#observe_histogram(name, value, tags = {}) ⇒ void

This method returns an undefined value.

Records a histogram entry

Parameters:

  • name (String, Symbol)

    Name of the histogram

  • value (String, Integer)

    Value to record

  • tags (Hash{Symbol=>String}) (defaults to: {})

    Tags to apply to this record



61
62
# File 'lib/dynflow/telemetry_adapters/abstract.rb', line 61

def observe_histogram(name, value, tags = {})
end

#set_gauge(name, value, tags = {}) ⇒ void

This method returns an undefined value.

Modifies a gauge

Parameters:

  • name (String, Symbol)

    Name of the gauge to increment

  • value (String, Integer)

    Step to change by

  • tags (Hash{Symbol=>String}) (defaults to: {})

    Tags to apply to this record



52
53
# File 'lib/dynflow/telemetry_adapters/abstract.rb', line 52

def set_gauge(name, value, tags = {})
end

#with_instance {|adapter| ... } ⇒ void

This method returns an undefined value.

Passes self into the block and evaulates it

Yield Parameters:

  • adapter (Abstract)

    the current telemetry adapter



68
69
70
# File 'lib/dynflow/telemetry_adapters/abstract.rb', line 68

def with_instance
  yield self if block_given?
end