newrelic-sidekiq-stats 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3e7412ea3426783a0101a493cca4277dd78e9769d01f7b0acee7a4e26f3ea0c3
4
+ data.tar.gz: f53e6aed272aa3cf6e50d99aef38bb24d9f7d074ea81a140d0566e2e9c7e3f60
5
+ SHA512:
6
+ metadata.gz: 04bcd0661446e05b51d29850f0f52a4bfd24a157f59453ca90e09a637cc1a0e2b6b8f64fae6b17ff2312e6bb54dde8633b03cf5f843717c7a9dcd24859882b5b
7
+ data.tar.gz: 7238230f969b74a85ff72a2a587946777e75fd83860940a69a1b61eba83e555d45e6601a59009d54e711b39fc2a72e48893ae9a6b037ddc1a3bc859a88c59537
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.4
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at benoist.claassen@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in newrelic-sidekiq-stats.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ newrelic-sidekiq-stats (0.0.1)
5
+ newrelic_rpm
6
+ sidekiq
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ connection_pool (2.2.3)
12
+ diff-lcs (1.3)
13
+ newrelic_rpm (6.11.0.365)
14
+ rack (2.2.2)
15
+ rack-protection (2.0.8.1)
16
+ rack
17
+ rake (12.3.3)
18
+ redis (4.2.1)
19
+ rspec (3.9.0)
20
+ rspec-core (~> 3.9.0)
21
+ rspec-expectations (~> 3.9.0)
22
+ rspec-mocks (~> 3.9.0)
23
+ rspec-core (3.9.2)
24
+ rspec-support (~> 3.9.3)
25
+ rspec-expectations (3.9.2)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.9.0)
28
+ rspec-mocks (3.9.1)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.9.0)
31
+ rspec-support (3.9.3)
32
+ sidekiq (6.0.7)
33
+ connection_pool (>= 2.2.2)
34
+ rack (~> 2.0)
35
+ rack-protection (>= 2.0.0)
36
+ redis (>= 4.1.0)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ newrelic-sidekiq-stats!
43
+ rake (~> 12.0)
44
+ rspec (~> 3.0)
45
+
46
+ BUNDLED WITH
47
+ 2.1.4
@@ -0,0 +1,61 @@
1
+ # Newrelic::Sidekiq::Stats
2
+
3
+ This is a NewRelic Sampler for Sidekiq custom metrics.
4
+ It will sample the Sidekiq stats and create a custom metric for NewRelic.
5
+ You can view the information in the NewRelic insights or in NewRelic One.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'newrelic-sidekiq-stats'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install newrelic-sidekiq-stats
22
+
23
+ ## Usage
24
+
25
+ * Install the gem
26
+ * Create a dashboard on the NewRelic insights or NewRelic One
27
+
28
+ NQRL example:
29
+ ```
30
+ SELECT rate(average(newrelic.timeslice.value), 1 minute)
31
+ FROM Metric
32
+ WHERE appName ='My App Name'
33
+ WITH METRIC_FORMAT 'Custom/Sidekiq/ScheduledSize'
34
+ TIMESERIES LIMIT 10 SINCE 1800 seconds ago
35
+ ```
36
+
37
+ Available metrics:
38
+
39
+ * `Custom/Sidekiq/ProcessedSize`
40
+ * `Custom/Sidekiq/FailedSize`
41
+ * `Custom/Sidekiq/ScheduledSize`
42
+ * `Custom/Sidekiq/RetrySize`
43
+ * `Custom/Sidekiq/DeadSize`
44
+ * `Custom/Sidekiq/EnqueuedSize`
45
+ * `Custom/Sidekiq/ProcessesSize`
46
+ * `Custom/Sidekiq/WorkersSize`
47
+
48
+ ## Development
49
+
50
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
51
+
52
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
53
+
54
+ ## Contributing
55
+
56
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/newrelic-sidekiq-stats. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/newrelic-sidekiq-stats/blob/master/CODE_OF_CONDUCT.md).
57
+
58
+
59
+ ## Code of Conduct
60
+
61
+ Everyone interacting in the Newrelic::Sidekiq::Stats project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/newrelic-sidekiq-stats/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "newrelic/sidekiq/stats"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,36 @@
1
+ require 'new_relic/agent/sampler'
2
+
3
+ module NewRelic
4
+ module Agent
5
+ module Samplers
6
+ class SidekiqSampler < NewRelic::Agent::Sampler
7
+ METRIC_MAP = {
8
+ processed: 'ProcessedSize',
9
+ failed: 'FailedSize',
10
+ scheduled_size: 'ScheduledSize',
11
+ retry_size: 'RetrySize',
12
+ dead_size: 'DeadSize',
13
+ enqueued: 'EnqueuedSize',
14
+ processes_size: 'ProcessesSize',
15
+ workers_size: 'WorkersSize',
16
+ }.freeze
17
+
18
+ named :sidekiq
19
+
20
+ def poll
21
+ return unless Sidekiq.server?
22
+
23
+ stats = Sidekiq::Stats.new
24
+ max_latency = Sidekiq::Queue.all.map(&:latency).max
25
+ ::NewRelic::Agent.logger.debug("Recording metric: Custom/Sidekiq/QueueLatency=#{max_latency}")
26
+ ::NewRelic::Agent.record_metric("Custom/Sidekiq/QueueLatency", max_latency)
27
+ METRIC_MAP.map do |key, name|
28
+ value = stats.public_send(key)
29
+ ::NewRelic::Agent.logger.debug("Recording metric: Custom/Sidekiq/#{name}=#{value}")
30
+ ::NewRelic::Agent.record_metric("Custom/Sidekiq/#{name}", value)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ module NewRelic
2
+ module SidekiqStats
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ require_relative 'lib/newrelic_sidekiq_stats/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "newrelic-sidekiq-stats"
5
+ spec.version = NewRelic::SidekiqStats::VERSION
6
+ spec.authors = ["Benoist Claassen"]
7
+ spec.email = ["benoist.claassen@gmail.com"]
8
+
9
+ spec.summary = %q{Send sidekiq queue stats to new relic}
10
+ spec.description = %q{Monitor the queue sizes with new relic}
11
+ spec.homepage = "https://github.com/benoist/newrelic-sidekiq-stats"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ # Specify which files should be added to the gem when it is released.
15
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
16
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency 'newrelic_rpm'
24
+ spec.add_dependency 'sidekiq'
25
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: newrelic-sidekiq-stats
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Benoist Claassen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-06-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: newrelic_rpm
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sidekiq
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Monitor the queue sizes with new relic
42
+ email:
43
+ - benoist.claassen@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".rspec"
50
+ - ".travis.yml"
51
+ - CODE_OF_CONDUCT.md
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - README.md
55
+ - Rakefile
56
+ - bin/console
57
+ - bin/setup
58
+ - lib/newrelic-sidekiq-stats.rb
59
+ - lib/newrelic_sidekiq_stats/version.rb
60
+ - newrelic-sidekiq-stats.gemspec
61
+ homepage: https://github.com/benoist/newrelic-sidekiq-stats
62
+ licenses: []
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 2.3.0
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubygems_version: 3.0.3
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Send sidekiq queue stats to new relic
83
+ test_files: []