Class: Mayu::Metrics::Collector::DataStore::MetricStore

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/mayu/metrics/collector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store, metric_name, metric_type:, metric_settings: {}) ⇒ MetricStore

Returns a new instance of MetricStore.



21
22
23
24
25
26
27
28
# File 'lib/mayu/metrics/collector.rb', line 21

def initialize(store, metric_name, metric_type:, metric_settings: {})
  @store = store
  @metric_name = metric_name
  @metric_type = metric_type
  @metric_settings = metric_settings
  @aggregation_mode =
    T.let(metric_settings.fetch(:aggregation, :sum), Symbol)
end

Instance Attribute Details

#storeObject (readonly)

Returns the value of attribute store.



11
12
13
# File 'lib/mayu/metrics/collector.rb', line 11

def store
  @store
end

Instance Method Details

#all_valuesObject



40
41
42
43
44
# File 'lib/mayu/metrics/collector.rb', line 40

def all_values
  @store
    .values_for_metric(@metric_name)
    .transform_values { aggregate(_1) }
end

#set(val:, labels: {}) ⇒ Object



36
37
# File 'lib/mayu/metrics/collector.rb', line 36

def set(val:, labels: {})
end