opbeat 0.9.2 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 157acc9610fffbf878154cc1ba1e7312a9b1f77f
4
- data.tar.gz: 50476185d45bfafca5ce68cb542e1abb0ffbef7b
3
+ metadata.gz: a7eb7b17e78cc8c9e7257b46b2c618c2d18b3ba0
4
+ data.tar.gz: a3927d888501b9806001a62724b24bb62ed70584
5
5
  SHA512:
6
- metadata.gz: 5ca3600ea88cae6d689c4a22cd5f25cb56a6a7682d374401b7010066e508201d03eb8d03756af6c2be4023153ccad7e7d50f9ef323ff8647562d8d79b1fdef8c
7
- data.tar.gz: 6a689d1070878453e1e4132c4a722177663c15f14c100dd3ee9d5c0c4f9ab5fc80d2fbb06f69bcf8a12d69ec7b5d4149ed0ea979e1cac3bbaa6d06f163809532
6
+ metadata.gz: 0564b45393548258cc052aff8d980b36f20577d674af39d83f11ca496edc40a4654a31d25164e07fb9eae998dd6bcea1b601dbd46c26e467179cbf362c64ce15
7
+ data.tar.gz: eb7013aea6c700e64308fd84c2d53424edd1a097b220c26df7af9375572b618d7c7a62b4a36951248c18179e6a95c20ea247a2b3cfc2d05308c217fe4badd0c5
data/README.md CHANGED
@@ -216,7 +216,26 @@ Opbeat.configure do |config|
216
216
  end
217
217
  ```
218
218
 
219
+ ## Async Delivery
219
220
 
221
+ When an error occurs, the notification is immediately sent to Opbeat.
222
+ This will hold up the client HTTP request as long as the request to
223
+ Opbeat is ongoing. Alternatively the agent can be configured to send
224
+ notifications asynchronously.
225
+
226
+ Example using a native Ruby `Thread`:
227
+
228
+ ```ruby
229
+ Opbeat.configure do |config|
230
+ config.async = lambda { |event|
231
+ Thread.new { Opbeat.send(event) }
232
+ }
233
+ end
234
+ ```
235
+
236
+ Using this decoupled approach you can easily implement this into your
237
+ existing background job infrastructure. The only requirement is that you
238
+ at some point call the `Opbeat.send` method with the `event` object.
220
239
 
221
240
  ## Testing
222
241
 
@@ -225,9 +244,7 @@ $ bundle install
225
244
  $ rake spec
226
245
  ```
227
246
 
228
-
229
247
  ## Resources
230
248
 
231
249
  * [Bug Tracker](http://github.com/opbeat/opbeat_ruby/issues)
232
250
  * [Code](http://github.com/opbeat/opbeat_ruby)
233
-
@@ -85,27 +85,38 @@ module Opbeat
85
85
  at_exit do
86
86
  if $!
87
87
  logger.debug "Caught a post-mortem exception: #{$!.inspect}"
88
- self.captureException($!)
88
+ self.capture_exception($!)
89
89
  end
90
90
  end
91
91
  end
92
92
  end
93
93
 
94
- def captureException(exception, options={})
95
- evt = Event.capture_exception(exception, options)
96
- send(evt) if evt
94
+ def capture_exception(exception, options={})
95
+ exception.set_backtrace caller unless exception.backtrace
96
+ if (evt = Event.from_exception(exception, options))
97
+ if self.configuration.async?
98
+ self.configuration.async.call(evt)
99
+ else
100
+ send(evt)
101
+ end
102
+ end
97
103
  end
98
104
 
99
- def captureMessage(message, options={})
100
- evt = Event.capture_message(message, options)
101
- send(evt) if evt
105
+ def capture_message(message, options={})
106
+ if (evt = Event.from_message(message, caller, options))
107
+ if self.configuration.async?
108
+ self.configuration.async.call(evt)
109
+ else
110
+ send(evt)
111
+ end
112
+ end
102
113
  end
103
114
 
104
115
  def set_context(options={})
105
116
  Event.set_context(options)
106
117
  end
107
118
 
108
- alias :capture_exception :captureException
109
- alias :capture_message :captureMessage
119
+ alias :captureException :capture_exception
120
+ alias :captureMessage :capture_message
110
121
  end
111
122
  end
@@ -39,42 +39,32 @@ module Opbeat
39
39
 
40
40
  class Client
41
41
 
42
- PROTOCOL_VERSION = '1.0'
43
42
  USER_AGENT = "opbeat-ruby/#{Opbeat::VERSION}"
44
- AUTH_HEADER_KEY = 'Authorization'
45
43
 
46
44
  attr_accessor :configuration
47
45
  attr_accessor :state
48
46
 
49
- def initialize(configuration)
50
- @configuration = configuration
51
- @state = ClientState.new configuration
52
- @processors = configuration.processors.map { |p| p.new(self) }
47
+ def initialize(conf)
48
+ raise Error.new('No server specified') unless conf.server
49
+ raise Error.new('No secret token specified') unless conf.secret_token
50
+ raise Error.new('No organization ID specified') unless conf.organization_id
51
+ raise Error.new('No app ID specified') unless conf.app_id
52
+
53
+ @configuration = conf
54
+ @state = ClientState.new conf
55
+ @processors = conf.processors.map { |p| p.new(self) }
56
+ @base_url = "#{conf.server}/api/v1/organizations/#{conf.organization_id}/apps/#{conf.app_id}"
57
+ @auth_header = 'Bearer ' + conf.secret_token
53
58
  end
54
59
 
55
60
  def conn
56
- # Error checking
57
- raise Error.new('No server specified') unless self.configuration[:server]
58
- raise Error.new('No secret token specified') unless self.configuration[:secret_token]
59
- raise Error.new('No organization ID specified') unless self.configuration[:organization_id]
60
- raise Error.new('No app ID specified') unless self.configuration[:app_id]
61
-
62
- Opbeat.logger.debug "Opbeat client connecting to #{self.configuration[:server]}"
63
- @base_url = self.configuration[:server] +
64
- "/api/v1/organizations/" +
65
- self.configuration[:organization_id] +
66
- "/apps/" + self.configuration[:app_id]
67
- @conn ||= Faraday.new(:url => @base_url, :ssl => {:verify => self.configuration.ssl_verification}) do |builder|
68
- builder.adapter Faraday.default_adapter
61
+ @conn ||= Faraday.new(@base_url) do |faraday|
62
+ Opbeat.logger.debug "Initializing connection to #{self.configuration.server}"
63
+ faraday.adapter Faraday.default_adapter
64
+ faraday.ssl[:verify] = self.configuration.ssl_verification
65
+ faraday.options[:timeout] = self.configuration.timeout if self.configuration.timeout
66
+ faraday.options[:open_timeout] = self.configuration.open_timeout if self.configuration.open_timeout
69
67
  end
70
-
71
- @conn.options[:timeout] = self.configuration[:timeout]
72
- @conn.options[:open_timeout] = self.configuration[:open_timeout]
73
- @conn
74
- end
75
-
76
- def generate_auth_header(data)
77
- 'Bearer ' + self.configuration[:secret_token]
78
68
  end
79
69
 
80
70
  def encode(event)
@@ -90,12 +80,15 @@ module Opbeat
90
80
  def send(url_postfix, message)
91
81
  begin
92
82
  response = self.conn.post @base_url + url_postfix do |req|
93
- req.headers['Content-Type'] = 'application/json'
94
83
  req.body = self.encode(message)
95
- req.headers[AUTH_HEADER_KEY] = self.generate_auth_header(req.body)
96
- req.headers["User-Agent"] = USER_AGENT
84
+ req.headers['Authorization'] = @auth_header
85
+ req.headers['Content-Type'] = 'application/json'
86
+ req.headers['Content-Length'] = req.body.bytesize.to_s
87
+ req.headers['User-Agent'] = USER_AGENT
97
88
  end
98
- if !response.status.between?(200, 299)
89
+ if response.status.between?(200, 299)
90
+ Opbeat.logger.info "Event logged successfully at " + response.headers["location"]
91
+ else
99
92
  raise Error.new("Error from Opbeat server (#{response.status}): #{response.body}")
100
93
  end
101
94
  rescue
@@ -115,9 +108,9 @@ module Opbeat
115
108
  end
116
109
 
117
110
  # Set the organization ID correctly
118
- event.organization = self.configuration[:organization_id]
119
- event.app = self.configuration[:app_id]
120
- Opbeat.logger.debug "Sending event #{event.id} to Opbeat"
111
+ event.organization = self.configuration.organization_id
112
+ event.app = self.configuration.app_id
113
+ Opbeat.logger.debug "Sending event to Opbeat"
121
114
  send("/errors/", event)
122
115
  end
123
116
 
@@ -44,6 +44,9 @@ module Opbeat
44
44
 
45
45
  attr_accessor :user_controller_method
46
46
 
47
+ # Optional Proc to be used to send events asynchronously
48
+ attr_reader :async
49
+
47
50
  def initialize
48
51
  self.server = ENV['OPBEAT_SERVER'] || "https://opbeat.com"
49
52
  self.secret_token = ENV['OPBEAT_SECRET_TOKEN'] if ENV['OPBEAT_SECRET_TOKEN']
@@ -55,9 +58,11 @@ module Opbeat
55
58
  self.excluded_exceptions = []
56
59
  self.processors = [Opbeat::Processor::SanitizeData]
57
60
  self.timeout = 1
61
+ self.open_timeout = 1
58
62
  self.backoff_multiplier = 2
59
63
  self.ssl_verification = true
60
64
  self.user_controller_method = 'current_user'
65
+ self.async = false
61
66
  end
62
67
 
63
68
  # Allows config options to be read like a hash
@@ -75,5 +80,12 @@ module Opbeat
75
80
  environments.include? current_environment
76
81
  end
77
82
 
83
+ def async=(value)
84
+ raise ArgumentError.new("async must be callable (or false to disable)") unless (value == false || value.respond_to?(:call))
85
+ @async = value
86
+ end
87
+
88
+ alias_method :async?, :async
89
+
78
90
  end
79
91
  end
@@ -94,7 +94,7 @@ module Opbeat
94
94
  data
95
95
  end
96
96
 
97
- def self.capture_exception(exc, options={}, &block)
97
+ def self.from_exception(exc, options={}, &block)
98
98
  configuration = Opbeat.configuration
99
99
  if exc.is_a?(Opbeat::Error)
100
100
  # Try to prevent error reporting loops
@@ -110,20 +110,18 @@ module Opbeat
110
110
  evt.message = "#{exc.class.to_s}: #{exc.message}"
111
111
  evt.level = :error
112
112
  evt.parse_exception(exc)
113
- if (exc.backtrace)
114
- evt.interface :stack_trace do |int|
115
- int.frames = exc.backtrace.reverse.map do |trace_line|
116
- int.frame {|frame| evt.parse_backtrace_line(trace_line, frame) }
117
- end
118
- evt.culprit = evt.get_culprit(int.frames)
113
+ evt.interface :stack_trace do |int|
114
+ int.frames = exc.backtrace.reverse.map do |trace_line|
115
+ int.frame {|frame| evt.parse_backtrace_line(trace_line, frame) }
119
116
  end
117
+ evt.culprit = evt.get_culprit(int.frames)
120
118
  end
121
119
  block.call(evt) if block
122
120
  end
123
121
  end
124
122
 
125
- def self.capture_rack_exception(exc, rack_env, options={}, &block)
126
- capture_exception(exc, options) do |evt|
123
+ def self.from_rack_exception(exc, rack_env, options={}, &block)
124
+ from_exception(exc, options) do |evt|
127
125
  evt.interface :http do |int|
128
126
  int.from_rack(rack_env)
129
127
  end
@@ -141,8 +139,8 @@ module Opbeat
141
139
  end
142
140
  end
143
141
 
144
- def self.capture_message(message, options={})
145
- configuration ||= Opbeat.configuration
142
+ def self.from_message(message, stack, options={})
143
+ configuration = Opbeat.configuration
146
144
  options = self.merge_context(options)
147
145
  self.new(options, configuration) do |evt|
148
146
  evt.message = message
@@ -150,6 +148,11 @@ module Opbeat
150
148
  evt.interface :message do |int|
151
149
  int.message = message
152
150
  end
151
+ evt.interface :stack_trace do |int|
152
+ int.frames = stack.reverse.map do |trace_line|
153
+ int.frame {|frame| evt.parse_backtrace_line(trace_line, frame) }
154
+ end
155
+ end
153
156
  end
154
157
  end
155
158
 
@@ -191,12 +194,6 @@ module Opbeat
191
194
  @user[:username] = user_obj.send(:username) rescue nil
192
195
  end
193
196
 
194
- # For cross-language compat
195
- class << self
196
- alias :captionException :capture_exception
197
- alias :captureMessage :capture_message
198
- end
199
-
200
197
  private
201
198
 
202
199
  def self.merge_context(options={})
@@ -17,7 +17,7 @@ if defined?(Delayed)
17
17
 
18
18
  rescue Exception => exception
19
19
  # Log error to Opbeat
20
- ::Opbeat.captureException(exception)
20
+ ::Opbeat.capture_exception(exception)
21
21
  # Make sure we propagate the failure!
22
22
  raise exception
23
23
  end
@@ -13,7 +13,7 @@ if defined?(Resque)
13
13
  # @param (see Resque::Failure::Base#save)
14
14
  # @return (see Resque::Failure::Base#save)
15
15
  def save
16
- ::Opbeat.captureException(exception)
16
+ ::Opbeat.capture_exception(exception)
17
17
  end
18
18
  end
19
19
  end
@@ -12,7 +12,7 @@ if defined? Sidekiq
12
12
  yield
13
13
  rescue Exception => ex
14
14
  raise ex if [Interrupt, SystemExit, SignalException].include? ex.class
15
- ::Opbeat.captureException(ex)
15
+ ::Opbeat.capture_exception(ex)
16
16
  raise
17
17
  end
18
18
  end
@@ -26,7 +26,7 @@ if defined? Sidekiq
26
26
  chain.add ::Opbeat::Integrations::Sidekiq
27
27
  end
28
28
  else
29
- config.error_handlers << Proc.new { |ex, ctx| ::Opbeat.captureException(ex) }
29
+ config.error_handlers << Proc.new { |ex, ctx| ::Opbeat.capture_exception(ex) }
30
30
  end
31
31
  end
32
32
  end
@@ -28,7 +28,7 @@ module Opbeat
28
28
  rescue Error => e
29
29
  raise # Don't capture Opbeat errors
30
30
  rescue Exception => e
31
- evt = Event.capture_rack_exception(e, env)
31
+ evt = Event.from_rack_exception(e, env)
32
32
  Opbeat.send(evt)
33
33
  raise
34
34
  end
@@ -36,7 +36,7 @@ module Opbeat
36
36
  error = env['rack.exception'] || env['sinatra.error']
37
37
 
38
38
  if error
39
- evt = Event.capture_rack_exception(error, env)
39
+ evt = Event.from_rack_exception(error, env)
40
40
  Opbeat.send(evt) if evt
41
41
  end
42
42
 
@@ -8,7 +8,7 @@ module Opbeat
8
8
 
9
9
  def render_exception_with_opbeat(env, exception)
10
10
  begin
11
- evt = Opbeat::Event.capture_rack_exception(exception, env)
11
+ evt = Opbeat::Event.from_rack_exception(exception, env)
12
12
  Opbeat.send(evt) if evt
13
13
  rescue
14
14
  ::Rails::logger.debug "Error capturing or sending exception #{$!}"
@@ -1,3 +1,3 @@
1
1
  module Opbeat
2
- VERSION = "0.9.2"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -3,10 +3,12 @@ require 'opbeat'
3
3
 
4
4
  describe Opbeat::Client do
5
5
  before do
6
-
7
6
  @configuration = Opbeat::Configuration.new
8
7
  @configuration.environments = ["test"]
9
8
  @configuration.current_environment = :test
9
+ @configuration.secret_token = 'test'
10
+ @configuration.organization_id = 'test'
11
+ @configuration.app_id = 'test'
10
12
  @client = Opbeat::Client.new(@configuration)
11
13
  allow(@client).to receive(:send)
12
14
  end
@@ -2,13 +2,13 @@ require File::expand_path('../../spec_helper', __FILE__)
2
2
  require 'opbeat'
3
3
 
4
4
  describe Opbeat::Event do
5
- describe '.capture_message' do
5
+ describe '.from_message' do
6
6
  let(:message) { 'This is a message' }
7
- let(:hash) { Opbeat::Event.capture_message(message).to_hash }
7
+ let(:hash) { Opbeat::Event.from_message(message, caller).to_hash }
8
8
 
9
9
  context 'for a Message' do
10
10
  it 'returns an event' do
11
- expect(Opbeat::Event.capture_message(message)).to be_a(Opbeat::Event)
11
+ expect(Opbeat::Event.from_message(message, caller)).to be_a(Opbeat::Event)
12
12
  end
13
13
 
14
14
  it "sets the message to the value passed" do
@@ -21,14 +21,18 @@ describe Opbeat::Event do
21
21
  end
22
22
  end
23
23
 
24
- describe '.capture_exception' do
24
+ describe '.from_exception' do
25
25
  let(:message) { 'This is a message' }
26
- let(:exception) { Exception.new(message) }
27
- let(:hash) { Opbeat::Event.capture_exception(exception).to_hash }
26
+ let(:exception) {
27
+ exc = Exception.new(message)
28
+ exc.set_backtrace caller
29
+ exc
30
+ }
31
+ let(:hash) { Opbeat::Event.from_exception(exception).to_hash }
28
32
 
29
33
  context 'for an Exception' do
30
34
  it 'returns an event' do
31
- expect(Opbeat::Event.capture_exception(exception)).to be_a(Opbeat::Event)
35
+ expect(Opbeat::Event.from_exception(exception)).to be_a(Opbeat::Event)
32
36
  end
33
37
 
34
38
  it "sets the message to the exception's message and type" do
@@ -56,7 +60,11 @@ describe Opbeat::Event do
56
60
  module Opbeat::Test
57
61
  class Exception < Exception; end
58
62
  end
59
- let(:exception) { Opbeat::Test::Exception.new(message) }
63
+ let(:exception) {
64
+ exc = Opbeat::Test::Exception.new(message)
65
+ exc.set_backtrace caller
66
+ exc
67
+ }
60
68
 
61
69
  it 'sends the module name as part of the exception info' do
62
70
  expect(hash['exception']['module']).to eq('Opbeat::Test')
@@ -66,7 +74,7 @@ describe Opbeat::Event do
66
74
  context 'for a Opbeat::Error' do
67
75
  let(:exception) { Opbeat::Error.new }
68
76
  it 'does not create an event' do
69
- expect(Opbeat::Event.capture_exception(exception)).to be_nil
77
+ expect(Opbeat::Event.from_exception(exception)).to be_nil
70
78
  end
71
79
  end
72
80
 
@@ -113,7 +121,7 @@ describe Opbeat::Event do
113
121
  context 'when there is user context' do
114
122
  it 'sends the context and is_authenticated' do
115
123
  Opbeat::Event.set_context(:user => {:id => 99})
116
- hash = Opbeat::Event.capture_exception(exception).to_hash
124
+ hash = Opbeat::Event.from_exception(exception).to_hash
117
125
  expect(hash['user']).to eq({:id => 99, :is_authenticated => true})
118
126
  end
119
127
  end
@@ -122,7 +130,7 @@ describe Opbeat::Event do
122
130
  it 'sends the context and is_authenticated' do
123
131
  extra_context = {:jobid => 99}
124
132
  Opbeat::Event.set_context(:extra => extra_context)
125
- hash = Opbeat::Event.capture_exception(exception).to_hash
133
+ hash = Opbeat::Event.from_exception(exception).to_hash
126
134
  expect(hash['extra']).to eq(extra_context)
127
135
  end
128
136
  end
@@ -22,9 +22,9 @@ end
22
22
  Delayed::Worker.backend = Delayed::Backend::Test::Job
23
23
 
24
24
  describe Delayed::Plugins::Opbeat do
25
- it 'should call Opbeat::captureException on erronous jobs' do
25
+ it 'should call Opbeat::capture_exception on erronous jobs' do
26
26
  test_exception = Exception.new("Test exception")
27
- expect(Opbeat).to receive(:captureException).with(test_exception)
27
+ expect(Opbeat).to receive(:capture_exception).with(test_exception)
28
28
 
29
29
  # Queue
30
30
  bomb = Bomb.new
@@ -6,34 +6,59 @@ describe Opbeat do
6
6
  @send = double("send")
7
7
  @event = double("event")
8
8
  allow(Opbeat).to receive(:send) { @send }
9
- allow(Opbeat::Event).to receive(:capture_message) { @event }
10
- allow(Opbeat::Event).to receive(:capture_exception) { @event }
9
+ allow(Opbeat::Event).to receive(:from_message) { @event }
10
+ allow(Opbeat::Event).to receive(:from_exception) { @event }
11
11
  end
12
12
 
13
- it 'captureMessage should send result of Event.capture_message' do
13
+ it 'capture_message should send result of Event.from_message' do
14
14
  message = "Test message"
15
- expect(Opbeat::Event).to receive(:capture_message).with(message, {})
15
+ expect(Opbeat::Event).to receive(:from_message).with(message, an_instance_of(Array), {})
16
16
  expect(Opbeat).to receive(:send).with(@event)
17
17
 
18
- Opbeat.captureMessage(message)
18
+ Opbeat.capture_message(message)
19
19
  end
20
20
 
21
- it 'captureMessage with options should send result of Event.capture_message' do
21
+ it 'capture_message with options should send result of Event.from_message' do
22
22
  message = "Test message"
23
23
  options = {:extra => {:hello => "world"}}
24
- expect(Opbeat::Event).to receive(:capture_message).with(message, options)
24
+ expect(Opbeat::Event).to receive(:from_message).with(message, an_instance_of(Array), options)
25
25
  expect(Opbeat).to receive(:send).with(@event)
26
26
 
27
- Opbeat.captureMessage(message, options)
27
+ Opbeat.capture_message(message, options)
28
28
  end
29
29
 
30
- it 'captureException should send result of Event.capture_exception' do
30
+ it 'capture_exception should send result of Event.from_exception' do
31
31
  exception = build_exception()
32
32
 
33
- expect(Opbeat::Event).to receive(:capture_exception).with(exception, {})
33
+ expect(Opbeat::Event).to receive(:from_exception).with(exception, {})
34
34
  expect(Opbeat).to receive(:send).with(@event)
35
35
 
36
- Opbeat.captureException(exception)
36
+ Opbeat.capture_exception(exception)
37
37
  end
38
38
 
39
+ context "async" do
40
+ it 'capture_message should send result of Event.from_message' do
41
+ async = lambda {}
42
+ message = "Test message"
43
+
44
+ expect(Opbeat::Event).to receive(:from_message).with(message, an_instance_of(Array), {})
45
+ expect(Opbeat).to_not receive(:send)
46
+ expect(async).to receive(:call).with(@event)
47
+
48
+ Opbeat.configuration.async = async
49
+ Opbeat.capture_message(message)
50
+ end
51
+
52
+ it 'capture_exception should send result of Event.from_exception' do
53
+ async = lambda {}
54
+ exception = build_exception()
55
+
56
+ expect(Opbeat::Event).to receive(:from_exception).with(exception, {})
57
+ expect(Opbeat).to_not receive(:send)
58
+ expect(async).to receive(:call).with(@event)
59
+
60
+ Opbeat.configuration.async = async
61
+ Opbeat.capture_exception(exception)
62
+ end
63
+ end
39
64
  end
@@ -35,14 +35,14 @@ describe Opbeat::Rack do
35
35
  @send = double("send")
36
36
  @event = double("event")
37
37
  allow(Opbeat).to receive(:send) { @send }
38
- allow(Opbeat::Event).to receive(:capture_rack_exception) { @event }
38
+ allow(Opbeat::Event).to receive(:from_rack_exception) { @event }
39
39
  end
40
40
 
41
41
  it 'should capture exceptions' do
42
42
  exception = build_exception()
43
43
  env = {}
44
44
 
45
- expect(Opbeat::Event).to receive(:capture_rack_exception).with(exception, env)
45
+ expect(Opbeat::Event).to receive(:from_rack_exception).with(exception, env)
46
46
  expect(Opbeat).to receive(:send).with(@event)
47
47
 
48
48
  app = lambda do |e|
@@ -57,7 +57,7 @@ describe Opbeat::Rack do
57
57
  exception = build_exception()
58
58
  env = {}
59
59
 
60
- expect(Opbeat::Event).to receive(:capture_rack_exception).with(exception, env)
60
+ expect(Opbeat::Event).to receive(:from_rack_exception).with(exception, env)
61
61
  expect(Opbeat).to receive(:send).with(@event)
62
62
 
63
63
  app = lambda do |e|
@@ -84,7 +84,7 @@ describe Opbeat::Rack do
84
84
  it 'should extract user info' do
85
85
  expected_user = TestController.new.current_user
86
86
 
87
- Opbeat::Event.capture_rack_exception(@exception, @env) do |event|
87
+ Opbeat::Event.from_rack_exception(@exception, @env) do |event|
88
88
  user = event.to_hash['user']
89
89
  expect(user[:id]).to eq(expected_user.id)
90
90
  expect(user[:email]).to eq(expected_user.email)
@@ -97,7 +97,7 @@ describe Opbeat::Rack do
97
97
  Opbeat.configuration.user_controller_method = :custom_user
98
98
  expected_user = TestController.new.custom_user
99
99
 
100
- Opbeat::Event.capture_rack_exception(@exception, @env) do |event|
100
+ Opbeat::Event.from_rack_exception(@exception, @env) do |event|
101
101
  user = event.to_hash['user']
102
102
  expect(user[:id]).to eq(expected_user.id)
103
103
  expect(user[:email]).to eq(expected_user.email)
@@ -110,7 +110,7 @@ describe Opbeat::Rack do
110
110
  Opbeat.configuration.user_controller_method = :missing_user_method
111
111
  expected_user = TestController.new.custom_user
112
112
 
113
- Opbeat::Event.capture_rack_exception(@exception, @env) do |event|
113
+ Opbeat::Event.from_rack_exception(@exception, @env) do |event|
114
114
  expect(event.user).to eq(nil)
115
115
  end
116
116
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opbeat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Watson Steen
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-01-08 00:00:00.000000000 Z
13
+ date: 2015-01-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday