Class: G5PromRails::MetricsContainer

Inherits:
Object
  • Object
show all
Includes:
SidekiqApplicationMetrics
Defined in:
lib/g5_prom_rails/metrics.rb

Constant Summary collapse

MODEL_COUNT_NAME =
:model_rows

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SidekiqApplicationMetrics

#initialize_sidekiq_application, #update_sidekiq_statistics

Constructor Details

#initialize(app) ⇒ MetricsContainer

Returns a new instance of MetricsContainer.



13
14
15
16
17
18
19
# File 'lib/g5_prom_rails/metrics.rb', line 13

def initialize(app)
  @app = app
  @per_process = Prometheus::Client::Registry.new
  @per_application = Prometheus::Client::Registry.new
  @model_count_gauge = @per_application.gauge(MODEL_COUNT_NAME, "model row counts")
  try(:initialize_sidekiq_application)
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



10
11
12
# File 'lib/g5_prom_rails/metrics.rb', line 10

def app
  @app
end

#per_applicationObject (readonly)

Returns the value of attribute per_application.



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

def per_application
  @per_application
end

#per_processObject (readonly)

Returns the value of attribute per_process.



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

def per_process
  @per_process
end

Instance Method Details

#update_model_count_gauge(*models) ⇒ Object



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

def update_model_count_gauge(*models)
  models.each do |model|
    @model_count_gauge.set(
      { app: app, model: model.name.tableize },
      model.count
    )
  end
end