scout_dogstatsd 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ce1f0adaa54a58afc6218dcea16e5ed0f0a8863e
4
+ data.tar.gz: d1323a15338c12b38c071dd1767211e2d6df17a4
5
+ SHA512:
6
+ metadata.gz: 4b949a201334db1ca15c7d8f828fe0cac1b5cefa0c768e2d58fc4ef6257333191702bb0cd62f4f7c170aeb217e4afec23693752028ff1b54e30b3a3f76d3acea
7
+ data.tar.gz: 747f3a4eec9f185b56474cf8976787a38362d6295c171fa1fdd7af87a1db5f9253443fcfb1f61004c6df11d3edf2590eacf35fba20ae904265d0ad3e821eaef8
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in scout_dogstatsd.gemspec
4
+ gemspec
5
+
6
+ # Load the gem locally if modifying core extension functionality
7
+ # gem 'scout_apm', path: '~/projects/scout_apm_ruby'
8
+
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Derek Haynes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # ScoutDogstatsd
2
+
3
+ [![Build Status](https://travis-ci.org/scoutapp/scout_dogstatsd_ruby.svg?branch=master)](https://travis-ci.org/scoutapp/scout_dogstatsd_ruby)
4
+
5
+ Want your Rails performance KPIs in your DogStatsD-compatible metric system with _almost_ zero effort? Of course you do! Meet `scout_dogstatsd`! This gem is an extension of the [Scout](https://scoutapp.com) Ruby monitoring agent ([`scout_apm`](https://github.com/scoutapp/scout_apm_ruby)), and makes it easy to create an app performance dashboard:
6
+
7
+ ![screen](https://s3-us-west-1.amazonaws.com/scout-blog/scout_dogstatsd/datadog_screen.png)
8
+
9
+ A [Scout](https://scoutapp.com) account isn't required, but it certainly makes getting to the source of app performance easier 😉.
10
+
11
+ ## Metrics
12
+
13
+ The following metrics are reported w/o any custom instrumentation steps:
14
+
15
+ | Metric Name | Type | Description |
16
+ | - | - | - |
17
+ web.duration_ms | histogram | The total duration of web requests in milliseconds
18
+ job.duration_ms | histogram | The total duration of background jobs (Sidekiq, DelayedJob, etc.) in milliseconds
19
+ web.error_count | counter | A count of web requests that throw an exception
20
+ job.error_count | counter | A count of background jobs that throw an exception
21
+ web.queue_time_ms | gauge | The [time spent in request queuing](http://help.apm.scoutapp.com/#request-queuing) in milliseconds
22
+ job.queue_time_ms | gauge | The time between when a job is inserted into a background job queue and when execution begins in milliseconds
23
+
24
+ ## Tags
25
+
26
+ These metrics are tagged too! Slice and dice! The following tags are added to each metric:
27
+
28
+ | Tag Name | Description |
29
+ | - | - |
30
+ app | The name of the app. See the [name](http://help.apm.scoutapp.com/#name) Scout config option.
31
+ hostname | The hostname of the app. See the [hostname](http://help.apm.scoutapp.com/#hostname) Scout config option.
32
+
33
+ Now, you can correlate app performance metrics with all of your other system metrics.
34
+
35
+ ## Monitoring Platforms that Support the DogStatsD Protocol
36
+
37
+ * DataDog
38
+ * SignalFx via the [collectd dogstatsd plugin](https://github.com/signalfx/signalfx-collectd-plugin/blob/master/src/dogstatsd.py)
39
+ * Prometheus via the [statsd exporter](https://github.com/prometheus/statsd_exporter)
40
+
41
+ ## Installation
42
+
43
+ Add this line to your application's Gemfile:
44
+
45
+ ```ruby
46
+ gem 'scout_dogstatsd'
47
+ ```
48
+
49
+ And then execute:
50
+
51
+ $ bundle
52
+
53
+ Or install it yourself as:
54
+
55
+ $ gem install scout_dogstatsd
56
+
57
+ ## Configuration
58
+
59
+ __1. Add a `config/initializers/scout_dogstatsd.rb` file to your Rails app:__
60
+
61
+ ```ruby
62
+ require 'datadog/statsd'
63
+ statsd = Datadog::Statsd.new('localhost', 8125)
64
+ ScoutDogstatsd.configure(statsd)
65
+ ```
66
+
67
+ __2. Add a `config/scout_apm.yml` file to your Rails app:__
68
+
69
+ _This step isn't required if you are already using Scout._
70
+
71
+ ```yaml
72
+ common: &defaults
73
+ monitor: true
74
+
75
+ development:
76
+ <<: *defaults
77
+ monitor: false # set to true to test in your development environment
78
+
79
+ production:
80
+ <<: *defaults
81
+ ```
82
+
83
+ _Metrics are only sent if `monitor: true` for the associated Rails environment._
84
+
85
+ [See the Scout docs](http://help.apm.scoutapp.com/#ruby-agent) for advanced configuration instructions.
86
+
87
+ ## How it works
88
+
89
+ After each transaction (a web request or background job), the metrics specific to that transaction are transmitted via the DogStatsD protocol via the client passed through to `ScoutDogstatsd#configure`. No code changes are required: the `scout_apm` gem automatically instruments Rails controller-actions and background jobs. Easy peasy!
90
+
91
+ ## Contributing
92
+
93
+ Bug reports and pull requests are welcome on GitHub at https://github.com/scoutapp/scout_dogstatsd_ruby.
94
+
95
+
96
+ ## License
97
+
98
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
99
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :test do
4
+ $: << File.expand_path(File.dirname(__FILE__) + "/test")
5
+ Dir.glob('./test/*_test.rb').each { |file| require file }
6
+ end
7
+
8
+ desc "Run tests"
9
+ task :default => :test
10
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "scout_dogstatsd"
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
data/bin/setup ADDED
@@ -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,18 @@
1
+ module ScoutDogstatsd
2
+ # All access to the agent is thru this class method to ensure multiple Agent instances are not initialized per-Ruby process.
3
+ def self.configure(dogstatsd_client)
4
+ @@client ||= dogstatsd_client
5
+ ScoutApm::Extensions::Config.add_transaction_callback(ScoutDogstatsd::TransactionCallback.new)
6
+ end
7
+
8
+ def self.client
9
+ @@client
10
+ end
11
+
12
+ def self.rails?
13
+ defined? Rails::Railtie
14
+ end
15
+ end
16
+
17
+ require "scout_dogstatsd/version"
18
+ require "scout_dogstatsd/transaction_callback"
@@ -0,0 +1,28 @@
1
+ module ScoutDogstatsd
2
+ class TransactionCallback
3
+ def call(payload)
4
+ @payload = payload
5
+ ScoutDogstatsd.client.batch do |s|
6
+ s.histogram("#{payload.transaction_type_slug}.duration_ms", payload.duration_ms, :tags => tags)
7
+
8
+ if payload.queue_time_ms
9
+ s.gauge("#{payload.transaction_type_slug}.queue_time_ms", payload.queue_time_ms, :tags => tags)
10
+ end
11
+
12
+ if payload.error?
13
+ s.increment("#{payload.transaction_type_slug}.error_count", :tags => tags)
14
+ end
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def tags
21
+ [
22
+ "hostname:#{@payload.hostname}",
23
+ "app:#{@payload.app_name}",
24
+ ]
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module ScoutDogstatsd
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'scout_dogstatsd/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "scout_dogstatsd"
8
+ spec.version = ScoutDogstatsd::VERSION
9
+ spec.authors = ["Derek Haynes"]
10
+ spec.email = ["derek.haynes@gmail.com"]
11
+
12
+ spec.summary = %q{Reports app performance KPIs (response time, error rate, throughput, etc) via the DogStatsD client}
13
+ spec.homepage = "https://github.com/scoutapp/scout_dogstatsd_ruby"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.11"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest"
24
+ spec.add_development_dependency "mocha"
25
+
26
+ spec.add_runtime_dependency "scout_apm", "~> 2.4.11.pre"
27
+ spec.add_runtime_dependency "dogstatsd-ruby"
28
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scout_dogstatsd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Derek Haynes
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-04-11 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.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mocha
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: scout_apm
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.4.11.pre
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.4.11.pre
83
+ - !ruby/object:Gem::Dependency
84
+ name: dogstatsd-ruby
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description:
98
+ email:
99
+ - derek.haynes@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - bin/console
110
+ - bin/setup
111
+ - lib/scout_dogstatsd.rb
112
+ - lib/scout_dogstatsd/transaction_callback.rb
113
+ - lib/scout_dogstatsd/version.rb
114
+ - scout_dogstatsd.gemspec
115
+ homepage: https://github.com/scoutapp/scout_dogstatsd_ruby
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.4.6
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: Reports app performance KPIs (response time, error rate, throughput, etc)
139
+ via the DogStatsD client
140
+ test_files: []