Last active
August 12, 2024 16:39
Revisions
-
jwicks revised this gist
Mar 31, 2015 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,12 @@ def perform namespace: 'Worker', metric_data: [{ metric_name: 'QueueSize', dimensions: [{ name: 'Environment', value: Rails.env }], value: queue_size, unit: 'Count' }] ) end -
jwicks renamed this gist
Mar 31, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jwicks created this gist
Mar 31, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ class QueueSizeMetricWorker include Sidekiq::Worker include Sidetiq::Schedulable recurrence { minutely } sidekiq_options retry: false # Publish a custom metric on CloudWatch with the Sidekiq queue size def perform cloudwatch = Aws::CloudWatch::Client.new( region: 'us-east-1', credentials: Aws::Credentials.new(ENV['AWS_KEY'], ENV['AWS_SECRET']) ) cloudwatch.put_metric_data( namespace: 'Worker', metric_data: [{ metric_name: 'QueueSize', value: queue_size }] ) end def queue_size stats = Sidekiq::Stats.new stats.queues.values.inject 0, :+ end end