newrelic-middleware 1.0.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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +36 -0
- data/Rakefile +10 -0
- data/lib/newrelic-middleware.rb +14 -0
- data/lib/newrelic-middleware/railtie.rb +7 -0
- data/lib/newrelic-middleware/version.rb +3 -0
- data/newrelic-middleware.gemspec +20 -0
- data/test/middleware_test.rb +15 -0
- data/test/rails_test.rb +8 -0
- data/test/test_helper.rb +32 -0
- metadata +88 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 twinturbo
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# New Relic: Middleware
|
2
|
+
|
3
|
+
Use this middleware to see how long your app is spending in middleware.
|
4
|
+
|
5
|
+
It does not track per middleware.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'newrelic-middleware'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install newrelic-middleware
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
use NewRelicMiddleware::TrackingSupport
|
25
|
+
run MyApp
|
26
|
+
```
|
27
|
+
|
28
|
+
No integration is required for Rails. It will add itself.
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "newrelic-middleware/version"
|
2
|
+
|
3
|
+
module NewRelicMiddleware
|
4
|
+
class TrackingSupport
|
5
|
+
def initialize(app)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
env["HTTP_X_MIDDLEWARE_START"] = "t=#{(Time.now.to_f * 1000000).to_i}"
|
11
|
+
@app.call env
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/newrelic-middleware/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["twinturbo"]
|
6
|
+
gem.email = ["me@broadcastingadam.com"]
|
7
|
+
gem.description = %q{Track time spent your middleware stack with New Relic}
|
8
|
+
gem.summary = %q{}
|
9
|
+
gem.homepage = "https://github.com/twinturbo/newrelic-middleware"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "newrelic-middleware"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = NewRelicMiddleware::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency "rails"
|
19
|
+
gem.add_development_dependency "rack-test"
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class MiddlewareTest < MiniTest::Unit::TestCase
|
4
|
+
include Rack::Test::Methods
|
5
|
+
|
6
|
+
def app
|
7
|
+
TestApp
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_adds_a_start_time_header
|
11
|
+
get '/'
|
12
|
+
assert last_response.ok?
|
13
|
+
assert last_response.headers['HTTP_X_MIDDLEWARE_START']
|
14
|
+
end
|
15
|
+
end
|
data/test/rails_test.rb
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
4
|
+
require 'newrelic-middleware'
|
5
|
+
|
6
|
+
require 'minitest/unit'
|
7
|
+
require 'minitest/pride'
|
8
|
+
require 'minitest/autorun'
|
9
|
+
|
10
|
+
require 'rack/test'
|
11
|
+
|
12
|
+
class HelloWorld
|
13
|
+
def self.call(env)
|
14
|
+
[200, env.slice('HTTP_X_MIDDLEWARE_START'), ["Hi"]]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
TestApp = Rack::Builder.new do
|
19
|
+
use NewRelicMiddleware::TrackingSupport
|
20
|
+
run HelloWorld
|
21
|
+
end
|
22
|
+
|
23
|
+
ENV['RAILS_ENV'] = "test"
|
24
|
+
|
25
|
+
require 'rails'
|
26
|
+
require 'action_controller/railtie'
|
27
|
+
require 'newrelic-middleware/railtie'
|
28
|
+
|
29
|
+
class TestRailsApp < Rails::Application
|
30
|
+
config.active_support.deprecation = proc { |message, stack| }
|
31
|
+
initialize!
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: newrelic-middleware
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- twinturbo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: &70156941959980 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70156941959980
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rack-test
|
27
|
+
requirement: &70156941959560 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70156941959560
|
36
|
+
description: Track time spent your middleware stack with New Relic
|
37
|
+
email:
|
38
|
+
- me@broadcastingadam.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- LICENSE
|
46
|
+
- README.md
|
47
|
+
- Rakefile
|
48
|
+
- lib/newrelic-middleware.rb
|
49
|
+
- lib/newrelic-middleware/railtie.rb
|
50
|
+
- lib/newrelic-middleware/version.rb
|
51
|
+
- newrelic-middleware.gemspec
|
52
|
+
- test/middleware_test.rb
|
53
|
+
- test/rails_test.rb
|
54
|
+
- test/test_helper.rb
|
55
|
+
homepage: https://github.com/twinturbo/newrelic-middleware
|
56
|
+
licenses: []
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
hash: 2035928544990081540
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
hash: 2035928544990081540
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.8.11
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: ''
|
85
|
+
test_files:
|
86
|
+
- test/middleware_test.rb
|
87
|
+
- test/rails_test.rb
|
88
|
+
- test/test_helper.rb
|