scout_statsd_rack 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +62 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/scout_statsd_rack.rb +34 -0
- data/lib/scout_statsd_rack/railtie.rb +7 -0
- data/lib/scout_statsd_rack/version.rb +3 -0
- data/scout_statsd_rack.gemspec +34 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ee8b7d13731c567210df38dcea502ccffdf52c0f
|
4
|
+
data.tar.gz: dfedd8d8ffbc096ac00168bdfdc924de1cce8736
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5240ffbd310c23b44652a70d9c90839daa8bc170e6789c7e16306440e976c24443567e624b1b8128469095c5def2a7081133d991a433e658de033efe5806db03
|
7
|
+
data.tar.gz: 711919933d5f422130c358cb95c28c9692f8c14826a3fd72b7aa08562122cc15a6b60bef33368e508c199f43d549781e0bf98bcbb9b4fa990766fccb5e5482d9
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Scout StatsD Rack
|
2
|
+
|
3
|
+
This instruments Ruby applications served by [Rack](http://rack.github.io/) with [StatsD](https://github.com/etsy/statsd/).
|
4
|
+
The gem is maintained by [Scout](https://scoutapp.com) for our [hosted StatsD](https://scoutapp.com/statsd) service but is compatible with any StatsD collector.
|
5
|
+
|
6
|
+
## Reported Metrics
|
7
|
+
|
8
|
+
The following metrics are reported:
|
9
|
+
|
10
|
+
* Response code rates (2XX,3XX,4XX,5XX,etc)
|
11
|
+
* Response time
|
12
|
+
* Request throughput
|
13
|
+
|
14
|
+
## Rails Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'scout_statsd_rack'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
That's it! The gem uses a Railtie that automatically includes the middleware instrumentation into your app.
|
27
|
+
|
28
|
+
## Non-Rails Installation
|
29
|
+
|
30
|
+
Add this line to your application's Gemfile:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
gem 'scout_statsd_rack'
|
34
|
+
```
|
35
|
+
|
36
|
+
And then execute:
|
37
|
+
|
38
|
+
$ bundle
|
39
|
+
|
40
|
+
Use the `ScoutStatsdRack` middleware:
|
41
|
+
|
42
|
+
use ScoutStatsdRack::Middleware
|
43
|
+
|
44
|
+
## Using with Scout
|
45
|
+
|
46
|
+
Just install the [Scoutd](http://help.scoutapp.com/docs/agent) agent on the host(s) serving the app to see the Rack metrics in the Scout UI.
|
47
|
+
|
48
|
+
## Scope
|
49
|
+
|
50
|
+
This gem is laser-focused on Rack-related metrics. Other `scout_statsd_X` gems instrument different areas of your code.
|
51
|
+
|
52
|
+
## Questions? Feedback?
|
53
|
+
|
54
|
+
[Create an issue](https://github.com/scoutapp/scout_statsd_rack/issues) or shoot an email to support@scoutapp.com.
|
55
|
+
|
56
|
+
## Contributing
|
57
|
+
|
58
|
+
1. Fork it ( https://github.com/[my-github-username]/scout_statsd_rack/fork )
|
59
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
60
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
61
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
62
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "scout_statsd_rack"
|
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,34 @@
|
|
1
|
+
require "scout_statsd_rack/version"
|
2
|
+
require "scout_statsd_rack/railtie"
|
3
|
+
require "statsd-ruby"
|
4
|
+
|
5
|
+
module ScoutStatsdRack
|
6
|
+
class Middleware
|
7
|
+
attr_accessor :app
|
8
|
+
|
9
|
+
def initialize(app)
|
10
|
+
@app = app
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(env)
|
14
|
+
(status, headers, body), response_time = call_with_timing(env)
|
15
|
+
statsd.timing("response", response_time)
|
16
|
+
statsd.increment("response_codes.#{status.to_s.gsub(/\d{2}$/,'xx')}")
|
17
|
+
# Rack response
|
18
|
+
[status, headers, body]
|
19
|
+
rescue Exception => exception
|
20
|
+
statsd.increment("response_codes.5xx")
|
21
|
+
raise
|
22
|
+
end
|
23
|
+
|
24
|
+
def call_with_timing(env)
|
25
|
+
start = Time.now
|
26
|
+
result = @app.call(env)
|
27
|
+
[result, ((Time.now - start) * 1000).round]
|
28
|
+
end
|
29
|
+
|
30
|
+
def statsd
|
31
|
+
@statsd ||= Statsd.new('localhost', 8125)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
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_rack/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "scout_statsd_rack"
|
8
|
+
spec.version = ScoutStatsdRack::VERSION
|
9
|
+
spec.authors = ["Mark Morris", "Derek Haynes"]
|
10
|
+
spec.email = ["support@scoutapp.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Basic Rack application monitoring with StatsD.}
|
13
|
+
spec.homepage = "https://scoutapp.com"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
+
# delete this section to allow pushing this gem to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
end
|
23
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
27
|
+
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_runtime_dependency "statsd-ruby", "~> 1.2"
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scout_statsd_rack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mark Morris
|
8
|
+
- Derek Haynes
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: statsd-ruby
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.2'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.2'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.9'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.9'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '10.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '10.0'
|
56
|
+
description:
|
57
|
+
email:
|
58
|
+
- support@scoutapp.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/scout_statsd_rack.rb
|
72
|
+
- lib/scout_statsd_rack/railtie.rb
|
73
|
+
- lib/scout_statsd_rack/version.rb
|
74
|
+
- scout_statsd_rack.gemspec
|
75
|
+
homepage: https://scoutapp.com
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata:
|
79
|
+
allowed_push_host: https://rubygems.org
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.2.2
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Basic Rack application monitoring with StatsD.
|
100
|
+
test_files: []
|
101
|
+
has_rdoc:
|