Class: Sidekiq::Metrics::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/metrics/stats.rb

Instance Method Summary collapse

Constructor Details

#initialize(influxdb_client:, series_name: 'sidekiq_stats', retention_policy: nil, tags: {}) ⇒ Stats

Returns a new instance of Stats.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/sidekiq/metrics/stats.rb', line 7

def initialize(
  influxdb_client:,
  series_name: 'sidekiq_stats',
  retention_policy: nil,
  tags: {}
)
  @influxdb = influxdb_client
  @series = series_name
  @retention = retention_policy
  @tags = tags
end

Instance Method Details

#publishObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sidekiq/metrics/stats.rb', line 19

def publish
  stats = Sidekiq::Stats.new.instance_variable_get(:@stats)
  stats.delete(:default_queue_latency)

  stats.each do |stat, size|
    save(
      tags: {stat: stat}.merge(@tags),
      values: {size: size}
    )
  end
end