Class: Yabeda::Histogram

Inherits:
Metric
  • Object
show all
Defined in:
lib/yabeda/histogram.rb

Overview

Base class for complex metric for measuring time values that allow to calculate averages, percentiles, and so on.

Instance Attribute Summary collapse

Attributes inherited from Metric

#aggregation, #comment, #group, #name, #per, #tags, #unit

Instance Method Summary collapse

Methods inherited from Metric

#get, #values

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

  • buckets (Object)

Instance Attribute Details

#bucketsObject (readonly)

Reader method for the buckets initializer parameter.



7
# File 'lib/yabeda/histogram.rb', line 7

option :buckets

Instance Method Details

#measure(tags, value) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/yabeda/histogram.rb', line 9

def measure(tags, value)
  all_tags = ::Yabeda::Tags.build(tags)
  values[all_tags] = value
  ::Yabeda.adapters.each do |_, adapter|
    adapter.perform_histogram_measure!(self, all_tags, value)
  end
  value
end