newrelic_sidekiq_agent 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bb6b46e12edf6d0786b6515fcec5bd34c60d18c4
4
+ data.tar.gz: 86e6b4b0b0188e050733ed8a2df48e617df9564c
5
+ SHA512:
6
+ metadata.gz: a8e8591d0e9896073621899422059262d24969640a9f154957747dc91d47465f3e1d92964955c8aac148c2c83733dbaeac8df6963cd07a97b485d0511c10cc58
7
+ data.tar.gz: 2759a1b7c427bbc6a8a0ef320d7a7ee451b87aba9d75dc425ba35c36f471437012b7a6d1a8e3f6ce1935ff2ec163b57a5f0017124f4f0b99ce5de39dfe481c03
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require "newrelic_sidekiq_agent"
3
+
4
+ require 'optparse'
5
+
6
+ options = OptionParser.new do |opts|
7
+ opts.banner = <<-EOF
8
+ Usage:
9
+ newrelic_sidekiq_agent [options]
10
+ EOF
11
+
12
+ opts.on("-v", "--verbose", "Run verbosely") do
13
+ NewRelic::Plugin::Config.config.newrelic['verbose'] = 1
14
+ end
15
+
16
+ opts.on("-c", "--config FILE", "Override the location of the newrelic_plugin.yml") do |filename|
17
+ if !File.exists? filename
18
+ puts "File not found: #{filename.inspect}"
19
+ exit 1
20
+ end
21
+
22
+ NewRelic::Plugin::Config.config_file = filename
23
+ end
24
+
25
+ opts.on("-h", "--help") do
26
+ puts opts
27
+ exit 0
28
+ end
29
+ end
30
+
31
+ args = options.parse!(ARGV)
32
+
33
+ NewRelicSidekiqPlugin.run
@@ -0,0 +1,57 @@
1
+ require 'uri'
2
+ require 'cgi'
3
+
4
+ require "newrelic_plugin"
5
+ require 'sidekiq'
6
+ require 'sidekiq/api'
7
+
8
+ module NewRelicSidekiqPlugin
9
+ VERSION = '0.1.0'
10
+
11
+ class Agent < NewRelic::Plugin::Agent::Base
12
+ agent_guid "com.modcloth.newrelic_plugin.sidekiq"
13
+ agent_version ::NewRelicSidekiqPlugin::VERSION
14
+ agent_config_options :name, :uri, :namespace
15
+ agent_human_labels("Sidekiq") do
16
+ u = ::URI.parse(uri)
17
+ name || "#{u.host}:#{u.port}"
18
+ end
19
+
20
+ def setup_metrics
21
+ Sidekiq.configure_client do |config|
22
+ config.redis = { url: uri, namespace: namespace }
23
+ end
24
+ @jobs_failed = NewRelic::Processor::EpochCounter.new
25
+ @jobs_processed = NewRelic::Processor::EpochCounter.new
26
+ end
27
+
28
+ def poll_cycle
29
+ stats = Sidekiq::Stats.new
30
+ workers = Sidekiq::Workers.new
31
+
32
+ report_metric 'Workers/Working', 'Workers', workers.size || 0
33
+
34
+ report_metric 'Jobs/Cardinality/Enqueued', 'Jobs', stats.enqueued || 0
35
+ report_metric 'Jobs/Cardinality/Processed', 'Jobs', stats.processed || 0
36
+ report_metric 'Jobs/Cardinality/Failed', 'Jobs', stats.failed || 0
37
+ report_metric 'Jobs/Cardinality/Scheduled', 'Jobs', stats.scheduled_size || 0
38
+ report_metric 'Jobs/Cardinality/Retries', 'Jobs', stats.retry_size || 0
39
+
40
+ report_metric 'Jobs/Rate/Processed', 'Jobs/sec', @jobs_processed.process(stats.processed || 0)
41
+ report_metric 'Jobs/Rate/Failed', 'Jobs/sec', @jobs_failed.process(stats.failed || 0)
42
+
43
+ stats.queues.each do |name, enqueued|
44
+ report_metric "Queues/Enqueued/#{name}", 'Jobs', enqueued || 0
45
+ report_metric "Queues/Latency/#{name}", 'Latency', Sidekiq::Queue.new(name).latency || 0
46
+ end
47
+ end
48
+ end
49
+
50
+ def self.run
51
+ NewRelic::Plugin::Config.config.agents.keys.each do |agent|
52
+ NewRelic::Plugin::Setup.install_agent agent, self
53
+ end
54
+
55
+ NewRelic::Plugin::Run.setup_and_run
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: newrelic_sidekiq_agent
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jesse Szwedko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: newrelic_plugin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 1.3.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.3.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: sidekiq
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 3.1.4
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 3.1.4
41
+ description: New Relic plugin for reporting Sidekiq statistics
42
+ email: j.szwedko@modcloth.com
43
+ executables:
44
+ - newrelic_sidekiq_agent
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - bin/newrelic_sidekiq_agent
49
+ - lib/newrelic_sidekiq_agent.rb
50
+ homepage: https://github.com/modcloth/newrelic_sidekiq_plugin
51
+ licenses:
52
+ - MIT
53
+ metadata: {}
54
+ post_install_message:
55
+ rdoc_options:
56
+ - --charset=UTF-8
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - '>='
62
+ - !ruby/object:Gem::Version
63
+ version: 1.9.3
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 2.0.3
72
+ signing_key:
73
+ specification_version: 2
74
+ summary: New Relic plugin for reporting Sidekiq statistics
75
+ test_files: []