scout_statsd 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: c5dcea9774fccaefcd3e2c41580b49c03e3a51f0
4
+ data.tar.gz: 2195978792707286259a77b1eae692bd6b6a34a2
5
+ SHA512:
6
+ metadata.gz: 3a2583bfe86a12d41f24bc88e86e818b2940372287c6741a7780e51e44289ae3eba906ea54ca4219e66f71f6c2c98dd7f99b36207d1b2f83e9636365c748d578
7
+ data.tar.gz: 63e1c6c123a56b75e3470e4f2512d42211bb80c0693485f9dc960ad5beb494fc738504179a3b7a1564456eac98aa712d94fee536ce7511d316f5223a660db675
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.0"
4
+ - "2.1"
5
+ - "2.2"
6
+ - "2.4"
7
+ - "2.5"
8
+ cache: bundler
9
+ before_install:
10
+ - gem update --system
11
+ - gem install bundler
12
+ jobs:
13
+ include:
14
+ - script: bundle exec rake test
15
+ rvm: "2.5"
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in scout_statsd.gemspec
4
+ gemspec
5
+
6
+ # Load the gem locally if modifying core extension functionality
7
+ # gem 'scout_apm', path: '~/projects/scout_apm_ruby'
8
+
@@ -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.
@@ -0,0 +1,81 @@
1
+ # ScoutStatsd
2
+
3
+ [![Build Status](https://travis-ci.org/scoutapp/scout_statsd_ruby.svg?branch=master)](https://travis-ci.org/scoutapp/scout_statsd_ruby)
4
+
5
+ Want your Rails performance KPIs in your StatsD-compatible metric system with _almost_ zero effort? Of course you do! Meet `scout_statsd`! 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
+ A [Scout](https://scoutapp.com) account isn't required, but it certainly makes getting to the source of app performance easier 😉.
8
+
9
+ ## Metrics
10
+
11
+ The following metrics are reported w/o any custom instrumentation steps:
12
+
13
+ | Metric Name | Type | Description |
14
+ | - | - | - |
15
+ web.duration_ms | timer | The total duration of web requests in milliseconds
16
+ job.duration_ms | timer | The total duration of background jobs (Sidekiq, DelayedJob, etc.) in milliseconds
17
+ web.error_count | counter | A count of web requests that throw an exception
18
+ job.error_count | counter | A count of background jobs that throw an exception
19
+ web.queue_time_ms | timer | The [time spent in request queuing](http://help.apm.scoutapp.com/#request-queuing) in milliseconds
20
+ job.queue_time_ms | timer | The time between when a job is inserted into a background job queue and when execution begins in milliseconds
21
+
22
+ Now, you can correlate app performance metrics with all of your other system metrics.
23
+
24
+ ## Installation
25
+
26
+ Add this line to your application's Gemfile:
27
+
28
+ ```ruby
29
+ gem 'scout_statsd'
30
+ ```
31
+
32
+ And then execute:
33
+
34
+ $ bundle
35
+
36
+ Or install it yourself as:
37
+
38
+ $ gem install scout_statsd
39
+
40
+ ## Configuration
41
+
42
+ __1. Add a `config/initializers/scout_statsd.rb` file to your Rails app:__
43
+
44
+ ```ruby
45
+ ScoutStatsd.configure(StatsD) # StatsD uses one of the statsd-instrument backends
46
+ ```
47
+
48
+ Note that `StatsD` is a [statsd-instrument](https://github.com/Shopify/statsd-instrument) client.
49
+
50
+ __2. Add a `config/scout_apm.yml` file to your Rails app:__
51
+
52
+ _This step isn't required if you are already using Scout._
53
+
54
+ ```yaml
55
+ common: &defaults
56
+ monitor: true
57
+
58
+ development:
59
+ <<: *defaults
60
+ monitor: false # set to true to test in your development environment
61
+
62
+ production:
63
+ <<: *defaults
64
+ ```
65
+
66
+ _Metrics are only sent if `monitor: true` for the associated Rails environment._
67
+
68
+ [See the Scout docs](http://help.apm.scoutapp.com/#ruby-agent) for advanced configuration instructions.
69
+
70
+ ## How it works
71
+
72
+ After each transaction (a web request or background job), the metrics specific to that transaction are transmitted via the StatsD protocol to the client passed through to `ScoutStatsd#configure`. No code changes are required: the `scout_apm` gem automatically instruments Rails controller-actions and background jobs. Easy peasy!
73
+
74
+ ## Contributing
75
+
76
+ Bug reports and pull requests are welcome on GitHub at https://github.com/scoutapp/scout_statsd_ruby.
77
+
78
+ ## License
79
+
80
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
81
+
@@ -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
+
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "scout_statsd"
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
@@ -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,20 @@
1
+ module ScoutStatsd
2
+ @@prefix ||= nil
3
+
4
+ def self.configure(options = {})
5
+ @@prefix ||= options[:prefix]
6
+ end
7
+
8
+ def self.prefix
9
+ @@prefix ? "#{@@prefix}." : ''
10
+ end
11
+
12
+ def self.rails?
13
+ defined? Rails::Railtie
14
+ end
15
+ end
16
+
17
+ require "scout_statsd/version"
18
+ require "scout_statsd/transaction_callback"
19
+
20
+ ScoutApm::Extensions::Config.add_transaction_callback(ScoutStatsd::TransactionCallback.new)
@@ -0,0 +1,16 @@
1
+ module ScoutStatsd
2
+ class TransactionCallback
3
+ def call(payload)
4
+ @payload = payload
5
+ StatsD.measure("#{ScoutStatsd.prefix}#{payload.transaction_type_slug}.duration_ms", payload.duration_ms)
6
+
7
+ if payload.queue_time_ms
8
+ StatsD.measure("#{ScoutStatsd.prefix}#{payload.transaction_type_slug}.queue_time_ms", payload.queue_time_ms)
9
+ end
10
+
11
+ if payload.error?
12
+ StatsD.increment("#{ScoutStatsd.prefix}#{payload.transaction_type_slug}.error_count")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module ScoutStatsd
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_statsd/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "scout_statsd"
8
+ spec.version = ScoutStatsd::VERSION
9
+ spec.authors = ["Derek Haynes", "Mike Stewart"]
10
+ spec.email = ["derek.haynes@gmail.com"]
11
+
12
+ spec.summary = %q{Reports app performance KPIs (response time, error rate, throughput, etc) via a StatsD client}
13
+ spec.homepage = "https://github.com/scoutapp/scout_statsd_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"
27
+ spec.add_runtime_dependency "statsd-instrument"
28
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scout_statsd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Derek Haynes
8
+ - Mike Stewart
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2018-05-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.11'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.11'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: minitest
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: mocha
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: scout_apm
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: 2.4.11
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: 2.4.11
84
+ - !ruby/object:Gem::Dependency
85
+ name: statsd-instrument
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ description:
99
+ email:
100
+ - derek.haynes@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - bin/console
112
+ - bin/setup
113
+ - lib/scout_statsd.rb
114
+ - lib/scout_statsd/transaction_callback.rb
115
+ - lib/scout_statsd/version.rb
116
+ - scout_statsd.gemspec
117
+ homepage: https://github.com/scoutapp/scout_statsd_ruby
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.4.6
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Reports app performance KPIs (response time, error rate, throughput, etc)
141
+ via a StatsD client
142
+ test_files: []