sidekiq-datadog-monitor 0.0.0

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: f45794395b62656e91167f2a556b145732800b08bc3a0b244145000a9dad33ea
4
+ data.tar.gz: a974754085c6e22572e8a8121996487fb5480e3beb550797a64c4e19a2f29486
5
+ SHA512:
6
+ metadata.gz: 83f1261fc742416237eca7175e268b7fb8ccdd30b1a7838ae7d7b0701446a8fad4c780e19366b7755ed6d38249dbde064c6303180ae7e7913fa1073b0ec57ad2
7
+ data.tar.gz: 23ebf0bf41c49d6ce143e340f6376a75b016d35b64ba36aebe53095986dad969dea0c7ce9790c70bcb39151cfc5bdba87c6554aac681f9e56d13fe9d121a2e89
@@ -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 56920003+oleksandra-k@users.noreply.github.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 [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
@@ -0,0 +1,43 @@
1
+ # Sidekiq::Datadog::Monitor
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sidekiq/datadog/monitor`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'sidekiq-datadog-monitor'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install sidekiq-datadog-monitor
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sidekiq-datadog-monitor. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Sidekiq::Datadog::Monitor project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/sidekiq-datadog-monitor/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sidekiq/datadog/monitor"
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,9 @@
1
+ require "sidekiq/datadog/monitor/version"
2
+
3
+ module Sidekiq
4
+ module Datadog
5
+ module Monitor
6
+ class Error < StandardError; end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,29 @@
1
+ require 'datadog/statsd'
2
+ require 'sidekiq/datadog/monitor/metrics_worker'
3
+ module Sidekiq
4
+ module Datadog
5
+ module Monitor
6
+ class Data
7
+ class << self
8
+ attr_reader :agent_port, :agent_host, :tag, :env, :queue, :cron
9
+
10
+ def initialize!(options)
11
+ @agent_port = options[:agent_port]
12
+ @agent_host = options[:agent_host]
13
+ @tag = options[:tag] || ''
14
+ @env = options[:env] || ''
15
+ @queue = options[:queue] || ''
16
+ @cron = options[:cron] || "*/1 * * * *"
17
+
18
+ start
19
+ end
20
+
21
+ def start
22
+ Sidekiq.set_schedule('send_metrics',
23
+ { "cron"=> cron, 'class' => 'Sidekiq::Datadog::Monitor::MetricsWorker', 'queue' => queue })
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,37 @@
1
+ require 'datadog/statsd'
2
+ require 'sidekiq'
3
+
4
+ module Sidekiq
5
+ module Datadog
6
+ module Monitor
7
+ class MetricsWorker
8
+ include Sidekiq::Worker
9
+
10
+ def perform
11
+ Sidekiq::Stats.new.queues.each_pair do |queue_name, size|
12
+ post_queue_size(queue_name, size)
13
+
14
+ post_queue_latency(queue_name)
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def statsd
21
+ @statsd = ::Datadog::Statsd.new(Data.agent_host, Data.agent_port)
22
+ end
23
+
24
+ def post_queue_size(queue_name, size)
25
+ statsd.gauge('sidekiq.queue.size', size,
26
+ tags: ["queue_name:#{queue_name}", "environment:#{Data.env}", Data.tag])
27
+ end
28
+
29
+ def post_queue_latency(queue_name)
30
+ latency = Sidekiq::Queue.new(queue_name).latency
31
+ statsd.gauge('sidekiq.queue.latency', latency,
32
+ tags: ["queue_name:#{queue_name}", "environment:#{Data.env}", Data.tag])
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,7 @@
1
+ module Sidekiq
2
+ module Datadog
3
+ module Monitor
4
+ VERSION = "0.0.0"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sidekiq-datadog-monitor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - aleksa_castle
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-10-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sidekiq
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.2'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 2.2.1
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '2.2'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 2.2.1
75
+ - !ruby/object:Gem::Dependency
76
+ name: dogstatsd-ruby
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '4.8'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 4.8.1
85
+ type: :runtime
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '4.8'
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 4.8.1
95
+ description:
96
+ email:
97
+ - oleksandra.k@matic.com
98
+ executables: []
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - CODE_OF_CONDUCT.md
103
+ - README.md
104
+ - bin/console
105
+ - bin/setup
106
+ - lib/sidekiq/datadog/monitor.rb
107
+ - lib/sidekiq/datadog/monitor/data.rb
108
+ - lib/sidekiq/datadog/monitor/metrics_worker.rb
109
+ - lib/sidekiq/datadog/monitor/version.rb
110
+ homepage: https://github.com/matic-insurance/sidekiq-datadog-monitor
111
+ licenses:
112
+ - MIT
113
+ metadata:
114
+ allowed_push_host: https://rubygems.org
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubygems_version: 3.0.8
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: A gem to gather and send sidekiq jobs metrics to datadog
134
+ test_files: []