Class: Yabeda::Metric

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/yabeda/metric.rb

Overview

Base class for all metrics

Direct Known Subclasses

Counter, Gauge, Histogram

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, **options) ⇒ Object

Parameters:

  • name

    Metric name. Use snake_case. E.g. job_runtime

  • options (Hash)

Options Hash (**options):

  • comment (Object) — default: nil

    Documentation string. Required by some adapters.

  • tags (Object) — default: nil

    Allowed labels to be set. Required by some adapters.

  • unit (Object) — default: nil

    In which units it is measured. E.g. `seconds`

  • per (Object) — default: nil

    Per which unit is measured `unit`. E.g. `call` as in seconds per call

  • group (Object) — default: nil

    Category name for grouping metrics

  • aggregation (Object) — default: nil

    How adapters should aggregate values from different processes

Instance Attribute Details

#aggregationObject (readonly)

How adapters should aggregate values from different processes

Reader method for the aggregation initializer parameter.


16
# File 'lib/yabeda/metric.rb', line 16

option :aggregation, optional: true, comment: "How adapters should aggregate values from different processes"

#commentObject (readonly)

Documentation string. Required by some adapters.

Reader method for the comment initializer parameter.


11
# File 'lib/yabeda/metric.rb', line 11

option :comment, optional: true, comment: "Documentation string. Required by some adapters."

#groupObject (readonly)

Category name for grouping metrics

Reader method for the group initializer parameter.


15
# File 'lib/yabeda/metric.rb', line 15

option :group,   optional: true, comment: "Category name for grouping metrics"

#nameObject (readonly)

Metric name. Use snake_case. E.g. job_runtime

Reader method for the name initializer parameter.


10
# File 'lib/yabeda/metric.rb', line 10

param  :name,                    comment: "Metric name. Use snake_case. E.g. job_runtime"

#perObject (readonly)

Per which unit is measured `unit`. E.g. `call` as in seconds per call

Reader method for the per initializer parameter.


14
# File 'lib/yabeda/metric.rb', line 14

option :per,     optional: true, comment: "Per which unit is measured `unit`. E.g. `call` as in seconds per call"

#tagsObject (readonly)

Allowed labels to be set. Required by some adapters.

Reader method for the tags initializer parameter.


12
# File 'lib/yabeda/metric.rb', line 12

option :tags,    optional: true, comment: "Allowed labels to be set. Required by some adapters."

#unitObject (readonly)

In which units it is measured. E.g. `seconds`

Reader method for the unit initializer parameter.


13
# File 'lib/yabeda/metric.rb', line 13

option :unit,    optional: true, comment: "In which units it is measured. E.g. `seconds`"

Instance Method Details

#get(labels = {}) ⇒ Object

Returns the value for the given label set


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

def get(labels = {})
  values[::Yabeda::Tags.build(labels)]
end

#valuesObject


23
24
25
# File 'lib/yabeda/metric.rb', line 23

def values
  @values ||= Concurrent::Hash.new
end