copperegg-apm 1.0.0.pre12 → 1.0.0.pre13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4313fab8e77ab385dea7347df5a08b45afac975
4
- data.tar.gz: 6a609b051cf3944274e61b6c9952bf88f8c7b8fe
3
+ metadata.gz: 23f4abd270317192f5473810d909a6ede98b8436
4
+ data.tar.gz: 2953b01b20c5a20ab52658cbb9b75c8935a853b9
5
5
  SHA512:
6
- metadata.gz: 94840a8bfcc2ea8f9ce4fc4136f215874a91581401b2a079735a5fdf8678ff082488a09d22fc4fefbf2627ac5cbf6f4c4f1611c0fc52e46f6827ae3676691d7b
7
- data.tar.gz: 8541bada34ccf547940bb757423f02659c60f3f1ec62d61bb7017eee973eab870219494c73a9b475cd0ace8978eed2b1ef2ec14a23e6d5481bb6f53425c9edf8
6
+ metadata.gz: a81b29b7c4c5b9d8128e31b83c3486a31c73dabfd884f1c2340a4f783abd2f01abc59a6e5e926e2ff98b458b7f0ad44ce2a4863a14b9836d81a4c883852e4109
7
+ data.tar.gz: a3e9ccd26ecd5d9d78f3e7daa81a6d5927fba18d859d460efede0fb4ec5052841513c4302fc09e96c57238a92d76ded6586b5789c9f31cf2242e4fd97563ed2e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- copperegg-apm (1.0.0.pre12)
4
+ copperegg-apm (1.0.0.pre13)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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 raised in your project will be aggregated by class, source location, and system.
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::RUM
241
+ use CopperEgg::APM::RUMBlender
232
242
 
233
243
  get '/hello' do
234
244
  'Hello World'
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 = "http://bacon.copperegg.com/bacon.gif"
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
@@ -9,7 +9,7 @@ module CopperEgg
9
9
  end
10
10
 
11
11
  def call(env)
12
- @app.call(env)
12
+ return @app.call(env)
13
13
  rescue Exception => e
14
14
  CopperEgg::APM.capture_exception(e)
15
15
  raise e
@@ -1,5 +1,5 @@
1
1
  module CopperEgg
2
2
  module APM
3
- GEM_VERSION = '1.0.0.pre12' unless defined? GEM_VERSION
3
+ GEM_VERSION = '1.0.0.pre13' unless defined? GEM_VERSION
4
4
  end
5
5
  end
@@ -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
- class ExceptionController < ApplicationController; end
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
- describe ExceptionController, :type => :controller do
19
- controller(ExceptionController) do
20
- def index
21
- @count = 1/0
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 :index, {:id => 1, :sort => "name"} }.to raise_error
27
-
28
- # last_payload = CopperEgg::APM.send(:class_variable_get, :@@payload_cache).split("\x00").select {|i| i.size > 2}.map {|i| i.sub(/^[^\{]+/,'')}.last
29
- # hash = JSON.parse last_payload
30
-
31
- # expect(hash.keys.sort).to eq ["excp", "id"]
32
- # expect(hash["id"]).to match(/\A[0-1a-z]{16}\z/i)
33
- # expect(hash["excp"].keys.sort).to eq ["error", "stacktrace", "ts"]
34
- # expect(hash["excp"]["error"]).to match(/\AZeroDivisionError\|/)
35
- # expect(hash["excp"]["error"]).to match(/\{Ruby\}\Z/)
36
- # expect(hash["excp"]["stacktrace"]).to match(/\Adivided by 0\n/)
37
- # expect(hash["excp"]["ts"]).to be_an_instance_of(Fixnum)
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.pre12
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-19 00:00:00.000000000 Z
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.pre12
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