sidekiq-datadog-monitor 0.2.0 → 0.2.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e6838bb59d76c94b8ca2e3ea015f7ab7af6081516f01e83e6a2d0a341d88b01
|
4
|
+
data.tar.gz: 5f209f188034fd94da47f3505eb758f264b5eb9149bdb9ffcb4ee172ad38f20c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
14
|
-
post_queue_size(queue_name, size)
|
13
|
+
statsd = ::Datadog::Statsd.new(Data.agent_host, Data.agent_port)
|
15
14
|
|
16
|
-
|
17
|
-
|
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
|
-
|
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))
|