copperegg-apm 1.0.0.pre12 → 1.0.0.pre13
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +12 -2
- data/copperegg_apm_test.db +0 -0
- data/lib/copperegg/apm/configuration.rb +1 -1
- data/lib/copperegg/apm/exception_capturer.rb +1 -1
- data/lib/copperegg/apm/version.rb +1 -1
- data/spec/action_controller_spec.rb +56 -20
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23f4abd270317192f5473810d909a6ede98b8436
|
4
|
+
data.tar.gz: 2953b01b20c5a20ab52658cbb9b75c8935a853b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a81b29b7c4c5b9d8128e31b83c3486a31c73dabfd884f1c2340a4f783abd2f01abc59a6e5e926e2ff98b458b7f0ad44ce2a4863a14b9836d81a4c883852e4109
|
7
|
+
data.tar.gz: a3e9ccd26ecd5d9d78f3e7daa81a6d5927fba18d859d460efede0fb4ec5052841513c4302fc09e96c57238a92d76ded6586b5789c9f31cf2242e4fd97563ed2e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -177,7 +177,17 @@ Outbound HTTP requests performed within your project will be benchmarked from an
|
|
177
177
|
|
178
178
|
## Exception Aggregation
|
179
179
|
|
180
|
-
When exception benchmarking is enabled, any exception
|
180
|
+
When exception benchmarking is enabled, any un-rescued exception in your project will be aggregated by class, source location, and system. This is performed using a middleware for Rack-based applications and an `at_exit` block for capturing exceptions that result in process termination.
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
config.benchmark_exceptions = true
|
184
|
+
```
|
185
|
+
|
186
|
+
For Rails projects, this will automatically add `CopperEgg::APM::ExceptionCapturer` to the middleware stack. For other Rack-based projects, add it to the middleware stack directly:
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
use CopperEgg::APM::ExceptionCapturer
|
190
|
+
```
|
181
191
|
|
182
192
|
## Real User Monitoring
|
183
193
|
|
@@ -228,7 +238,7 @@ require 'sinatra'
|
|
228
238
|
require 'copperegg_apm_config'
|
229
239
|
|
230
240
|
use Rack::Lint
|
231
|
-
use CopperEgg::APM::
|
241
|
+
use CopperEgg::APM::RUMBlender
|
232
242
|
|
233
243
|
get '/hello' do
|
234
244
|
'Hello World'
|
data/copperegg_apm_test.db
CHANGED
Binary file
|
@@ -12,7 +12,7 @@ module CopperEgg
|
|
12
12
|
@@app_root = ""
|
13
13
|
@@instrument_key = nil
|
14
14
|
@@rum_short_url = false
|
15
|
-
@@rum_beacon_url = "
|
15
|
+
@@rum_beacon_url = "//bacon.copperegg.com/bacon.gif"
|
16
16
|
@@gem_root = File.dirname(File.dirname(__FILE__))
|
17
17
|
@@log_to = nil
|
18
18
|
@@benchmark_sql = true
|
@@ -1,8 +1,17 @@
|
|
1
|
-
# Props to @relishapp (http://www.relishapp.com/rspec/rspec-rails/docs/controller-specs/anonymous-controller) and
|
2
|
-
# @AlexandrZaytsev (http://say26.com/rspec-testing-controllers-outside-of-a-rails-application) for their helpful blog posts
|
3
1
|
require File.dirname(__FILE__) + '/helpers/rails'
|
4
2
|
require 'spec_helper'
|
5
3
|
require 'rack/test'
|
4
|
+
require 'benchmark'
|
5
|
+
|
6
|
+
$without_middleware = "Controller without middleware: "
|
7
|
+
$with_middleware = "Controller with middleware: "
|
8
|
+
|
9
|
+
at_exit do
|
10
|
+
puts "\nMiddleware benchmarks:\n"
|
11
|
+
puts $without_middleware
|
12
|
+
puts $with_middleware
|
13
|
+
puts ""
|
14
|
+
end
|
6
15
|
|
7
16
|
RSpec.configure do |c|
|
8
17
|
c.infer_base_class_for_anonymous_controllers = true
|
@@ -10,30 +19,57 @@ end
|
|
10
19
|
|
11
20
|
class ApplicationController < ActionController::Base
|
12
21
|
include Rails.application.routes.url_helpers
|
22
|
+
end
|
23
|
+
|
24
|
+
class ControllerWithoutMiddleware < ApplicationController; end
|
25
|
+
|
26
|
+
class ControllerWithMiddleware < ApplicationController; end
|
27
|
+
|
28
|
+
class ControllerWithException < ApplicationController; end
|
29
|
+
|
30
|
+
describe ControllerWithMiddleware, :type => :controller do
|
13
31
|
include Rack::Test::Methods
|
32
|
+
|
33
|
+
let(:action) { lambda { |env| [200, {'Content-Type' => 'text/plain'}, "Hello world"] } }
|
34
|
+
let(:app) { CopperEgg::APM::ExceptionCapturer.new(action) }
|
35
|
+
|
36
|
+
it "should process request" do
|
37
|
+
$with_middleware << Benchmark.realtime do
|
38
|
+
1000.times { get "/" }
|
39
|
+
end.to_s
|
40
|
+
end
|
14
41
|
end
|
15
42
|
|
16
|
-
|
43
|
+
describe ControllerWithoutMiddleware, :type => :controller do
|
44
|
+
include Rack::Test::Methods
|
45
|
+
|
46
|
+
let(:app) { lambda { |env| [200, {'Content-Type' => 'text/plain'}, "Hello world"] } }
|
17
47
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
48
|
+
it "should process request" do
|
49
|
+
$without_middleware << Benchmark.realtime do
|
50
|
+
1000.times { get "/" }
|
51
|
+
end.to_s
|
23
52
|
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe ControllerWithException, :type => :controller do
|
56
|
+
include Rack::Test::Methods
|
57
|
+
|
58
|
+
let(:action) { lambda { |env| 1/0 } }
|
59
|
+
let(:app) { CopperEgg::APM::ExceptionCapturer.new(action) }
|
24
60
|
|
25
61
|
it "should instrument all exceptions not rescued" do
|
26
|
-
expect { get
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
62
|
+
expect { get "/" }.to raise_error
|
63
|
+
|
64
|
+
last_payload = CopperEgg::APM.send(:class_variable_get, :@@payload_cache).split("\x00").select {|i| i.size > 2}.map {|i| i.sub(/^[^\{]+/,'')}.last
|
65
|
+
hash = JSON.parse last_payload
|
66
|
+
|
67
|
+
expect(hash.keys.sort).to eq ["excp", "id"]
|
68
|
+
expect(hash["id"]).to match(/\A[0-1a-z]{16}\z/i)
|
69
|
+
expect(hash["excp"].keys.sort).to eq ["error", "stacktrace", "ts"]
|
70
|
+
expect(hash["excp"]["error"]).to match(/\AZeroDivisionError\|/)
|
71
|
+
expect(hash["excp"]["error"]).to match(/\{Ruby\}\Z/)
|
72
|
+
expect(hash["excp"]["stacktrace"]).to match(/\Adivided by 0\n/)
|
73
|
+
expect(hash["excp"]["ts"]).to be_an_instance_of(Fixnum)
|
38
74
|
end
|
39
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: copperegg-apm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.pre13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Bradford
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -304,7 +304,7 @@ rubyforge_project:
|
|
304
304
|
rubygems_version: 2.0.3
|
305
305
|
signing_key:
|
306
306
|
specification_version: 4
|
307
|
-
summary: copperegg-apm-1.0.0.
|
307
|
+
summary: copperegg-apm-1.0.0.pre13
|
308
308
|
test_files:
|
309
309
|
- spec/action_controller_spec.rb
|
310
310
|
- spec/apm_spec.rb
|