Class: ModularizationStatistics::GaugeMetric

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/modularization_statistics/gauge_metric.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for(metric_name, count, tags) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/modularization_statistics/gauge_metric.rb', line 12

def self.for(metric_name, count, tags)
  name = "modularization.#{metric_name}"
  # https://docs.datadoghq.com/metrics/custom_metrics/#naming-custom-metrics
  # Metric names must not exceed 200 characters. Fewer than 100 is preferred from a UI perspective
  if name.length > 200
    raise StandardError.new("Metrics names must not exceed 200 characters: #{name}") # rubocop:disable Style/RaiseArgs
  end

  new(
    name: name,
    count: count,
    tags: tags
  )
end

Instance Method Details

#==(other) ⇒ Object



33
34
35
36
37
# File 'lib/modularization_statistics/gauge_metric.rb', line 33

def ==(other)
  other.name == self.name &&
    other.count == self.count &&
    other.tags == self.tags
end

#to_sObject



28
29
30
# File 'lib/modularization_statistics/gauge_metric.rb', line 28

def to_s
  "#{name} with count #{count}, with tags #{tags.map(&:to_s).join(', ')}"
end