sidekiq-datadog-monitor 0.1.3 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -10
- data/lib/sidekiq/datadog/monitor/data.rb +2 -1
- data/lib/sidekiq/datadog/monitor/metrics_worker.rb +12 -8
- data/lib/sidekiq/datadog/monitor/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c04993e0a9efbddc006b53502d5e377bb775f98b544ae36ecb1a6b24e17752fe
|
4
|
+
data.tar.gz: 68c263c5a0a6d21add4a9c868ac3ca947e96f52625d33f3bc00bfdf0eb58b877
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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'
|
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
|
-
|
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))
|
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.
|
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:
|
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.
|
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
|