sidekiq-datadog-monitor 0.1.3 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f39776d67b0d9e04bcba82941af3b959286238613a9caf3a5a4441bafab2be7
4
- data.tar.gz: 7c09d4302aa6ba33fcb47594b0fd07258e8ac223d4f8b7ecc305e98f537b8d16
3
+ metadata.gz: c04993e0a9efbddc006b53502d5e377bb775f98b544ae36ecb1a6b24e17752fe
4
+ data.tar.gz: 68c263c5a0a6d21add4a9c868ac3ca947e96f52625d33f3bc00bfdf0eb58b877
5
5
  SHA512:
6
- metadata.gz: 8ed5f31a56a46e1bb3296cc99025ea68c098c41528cba06c92e4892762ec86a4decfc9989cd30ea7a38d50a0666d53459b9cd25aad1109af676e4e1c9598c31b
7
- data.tar.gz: ae0dfb2ded81b2b23a476b8269366d164d9aea9b3a8d1f021e6e449503b5346ebdec18901c276684e816197771c9db33b2cc11bef009685ae5c6dca57a1ff5c1
6
+ metadata.gz: f3cc0f0810615b74e94606bb4b60426b0c9f8cdaf78a6ecce2779d6953b1fa6b9f5078aac4b3e6973416b44c97b0f8702f22ca9893ba09a395e1d5381ffd65a4
7
+ data.tar.gz: 101d6fd9ad29331d288cfa2850d4c444308dafbf6be9c433a36164ffecdcd94d13730d363c80caf56a99b9eb0c30c0c9befac08ecdd9be4251f5f845c24b2149
data/README.md CHANGED
@@ -8,7 +8,7 @@ and send it to datadog
8
8
  Add this line to your application's Gemfile:
9
9
 
10
10
  ```ruby
11
- gem 'sidekiq-datadog-monitor', '0.0.1'
11
+ gem 'sidekiq-datadog-monitor'
12
12
  ```
13
13
 
14
14
  And then execute:
@@ -29,16 +29,15 @@ require 'sidekiq/datadog/monitor/data'
29
29
 
30
30
  # Initiate a Sidekiq::Datadog::Monitor client instance.
31
31
  Sidekiq::Datadog::Monitor::Data.initialize!(
32
- {agent_host: 'localhost',
33
- agent_port: 8125,
34
- queue: 'queue name',
35
- tags: ['env:production', 'product:product_name'], # optional
36
- cron: "*/30 * * * *" # default: "*/1 * * * *"
37
- }
38
- )
39
-
32
+ agent_host: 'localhost',
33
+ agent_port: 8125,
34
+ queue: 'queue name',
35
+ tags: ['env:production', 'product:product_name'], # optional
36
+ cron: "*/30 * * * *" # default: "*/1 * * * *",
37
+ batch: false # optional, default: false
38
+ )
40
39
  ```
41
- `agent_host` and `agent_port` instantiate DogStatsD client
40
+ `agent_host` and `agent_port` instantiate DogStatsD client
42
41
 
43
42
  `queue` setting for background job that will gather and send Sidekiq metrics
44
43
 
@@ -46,6 +45,7 @@ Sidekiq::Datadog::Monitor::Data.initialize!(
46
45
 
47
46
  `cron` - schedule settings for background job that will gather and send Sidekiq metrics
48
47
 
48
+ `batch` turns on sending DD metrics in batches. Make sure you don't have too many queues before enabling this option. The message with all tags must fit into [8KB of default DataDog buffer](https://docs.datadoghq.com/developers/dogstatsd/high_throughput/#enable-buffering-on-your-client) size.
49
49
 
50
50
 
51
51
  ## Development
@@ -3,12 +3,13 @@ module Sidekiq
3
3
  module Monitor
4
4
  class Data
5
5
  class << self
6
- attr_reader :agent_port, :agent_host, :tags, :env, :queue, :cron
6
+ attr_reader :agent_port, :agent_host, :tags, :env, :queue, :cron, :batch
7
7
 
8
8
  def initialize!(options)
9
9
  @agent_port, @agent_host, @queue = options.fetch_values(:agent_port, :agent_host, :queue)
10
10
  @tags = options[:tags] || []
11
11
  @cron = options[:cron] || '*/1 * * * *'
12
+ @batch = options[:batch] || false
12
13
 
13
14
  Sidekiq.configure_server do |config|
14
15
  SidekiqScheduler::Scheduler.dynamic = true
@@ -10,25 +10,29 @@ module Sidekiq
10
10
  sidekiq_options retry: false
11
11
 
12
12
  def perform
13
- Sidekiq::Stats.new.queues.each_pair do |queue_name, size|
14
- post_queue_size(queue_name, size)
13
+ statsd = ::Datadog::Statsd.new(Data.agent_host, Data.agent_port)
15
14
 
16
- post_queue_latency(queue_name)
17
- end
15
+ return send_metrics(statsd) unless Data.batch
16
+
17
+ statsd.batch { |batch_statsd| send_metrics(batch_statsd) }
18
18
  end
19
19
 
20
20
  private
21
21
 
22
- def statsd
23
- @statsd = ::Datadog::Statsd.new(Data.agent_host, Data.agent_port)
22
+ def send_metrics(statsd)
23
+ Sidekiq::Stats.new.queues.each_pair do |queue_name, size|
24
+ post_queue_size(statsd, queue_name, size)
25
+
26
+ post_queue_latency(statsd, queue_name)
27
+ end
24
28
  end
25
29
 
26
- def post_queue_size(queue_name, size)
30
+ def post_queue_size(statsd, queue_name, size)
27
31
  statsd.gauge('sidekiq.queue.size', size,
28
32
  tags: ["queue_name:#{queue_name}"].concat(Data.tags))
29
33
  end
30
34
 
31
- def post_queue_latency(queue_name)
35
+ def post_queue_latency(statsd, queue_name)
32
36
  latency = Sidekiq::Queue.new(queue_name).latency
33
37
  statsd.gauge('sidekiq.queue.latency', latency,
34
38
  tags: ["queue_name:#{queue_name}"].concat(Data.tags))
@@ -1,7 +1,7 @@
1
1
  module Sidekiq
2
2
  module Datadog
3
3
  module Monitor
4
- VERSION = '0.1.3'.freeze
4
+ VERSION = '0.2.2'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-datadog-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - aleksa_castle
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-03 00:00:00.000000000 Z
11
+ date: 2022-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0'
173
173
  requirements: []
174
- rubygems_version: 3.0.8
174
+ rubygems_version: 3.0.6
175
175
  signing_key:
176
176
  specification_version: 4
177
177
  summary: A gem to gather and send sidekiq jobs metrics to datadog