sidekiq-datadog-monitor 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e57d12d076f185cf465a993f9c74239247bb01740670ad9726b8ff62b5feaa2
4
- data.tar.gz: 88c0ecaac6266b2d7008e8ffa656cfa67f4819c627a0192d2c44dae93d9d1879
3
+ metadata.gz: 1e6838bb59d76c94b8ca2e3ea015f7ab7af6081516f01e83e6a2d0a341d88b01
4
+ data.tar.gz: 5f209f188034fd94da47f3505eb758f264b5eb9149bdb9ffcb4ee172ad38f20c
5
5
  SHA512:
6
- metadata.gz: 2acfe7817aab4ff8d841cf0b0a2b7608f9a3ba2fc1910a6678892de0e0938c83584f1a480df4678f0d9f80c47a436e1d72866a30b09edd8a8f804166eeb3593c
7
- data.tar.gz: 6ed78e731a72dca0a96e63995e0de25327af1a4a21dd9105873f64140d13161c23764d4591c46b39f03da9485125307e3553b1273616d2a814e9671b6a0cf67b
6
+ metadata.gz: c89749c8150eecc3cde7a9c6d121c902a7dd4b67f542ca664e5b7f4f95a70b90da1ad802c3e46c461fff8010376aac6565dc24f0be45afaf622fb9845e5f54be
7
+ data.tar.gz: eef31d5da46a77f797be7ca049d4bf8656b5f888ab648ec6608c8f526a84e9282cf8f938d750dc0c6336e2b40e92cdad2ef0e9c908b2c12a2f936fa0d705bc5a
data/README.md CHANGED
@@ -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.2.0'.freeze
4
+ VERSION = '0.2.1'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-datadog-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - aleksa_castle