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

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

Defined Under Namespace

Classes: MetricStore

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(internal_store = {}) ⇒ DataStore

Returns a new instance of DataStore.



69
70
71
# File 'lib/mayu/metrics/collector.rb', line 69

def initialize(internal_store = {})
  @internal_store = internal_store
end

Instance Attribute Details

#internal_storeObject (readonly)

Returns the value of attribute internal_store.



66
67
68
# File 'lib/mayu/metrics/collector.rb', line 66

def internal_store
  @internal_store
end

Instance Method Details

#for_metric(metric_name, metric_type:, metric_settings: {}) ⇒ Object



95
96
97
# File 'lib/mayu/metrics/collector.rb', line 95

def for_metric(metric_name, metric_type:, metric_settings: {})
  MetricStore.new(self, metric_name, metric_type:, metric_settings: {})
end

#values_for_metric(metric_name) ⇒ Object



78
79
80
81
82
83
84
85
86
# File 'lib/mayu/metrics/collector.rb', line 78

def values_for_metric(metric_name)
  @internal_store
    .values
    .map { _1[metric_name] }
    .compact
    .each_with_object(Hash.new { |h, k| h[k] = [] }) do |entries, obj|
      entries.each { |labels, value| obj[labels] << value }
    end
end