sentry-raven 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sentry-raven might be problematic. Click here for more details.

@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MjJjMTY3MzJiNDY3OWVlZmQyZTFlMmI4NTM1ZTUyZmVkMjZmN2U3Yw==
5
+ data.tar.gz: !binary |-
6
+ NDRlMmE4ZGZiZTViNjZkMjQ0MGQxMDVjZmMyNzZkZmFkMzE1OWUxYg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ OTdlZjZjMTZlMGQ4YTEzYWY4OGYwMjkzNzExZDhmNzUzNjg5NDJhZDhjMzc3
10
+ MTE4MWRkMTY3NGQ1YTE5Y2UzOTA5ZDdhNjY5NmY2ZWNjYzhjYTAxNmZhYjdl
11
+ MThmN2NkZWEzNzg1MmQ0YWQyNWQ4NDMzOTI1NjZjNTQ2OWQ0MzI=
12
+ data.tar.gz: !binary |-
13
+ M2M5ZTRjNGFkYmZkMDM3MTRjYzgxNGI0OGRjZjIyY2U5NTgyNmE0ZTJjNjEx
14
+ ZjRjMDQyYTUwZTIxZDE2NTg4MWMzYmY5OTkyZmM3Yjk4M2VjMmQ0MmYzMzYy
15
+ ZGQzYWI3ODhmMjY4NDNhYzk5ZmRjMzkxYTI0OTIxNDcwZjgwZTQ=
data/README.md CHANGED
@@ -26,7 +26,7 @@ For alternative configuration methods, and other options see [Configuration](#co
26
26
 
27
27
  ### Rails 3
28
28
 
29
- In Rails 3, Sentry will "just work," capturing any exceptions thrown in your app. All Rails integrations also
29
+ In Rails 3, Sentry will "just work" capturing any exceptions thrown in your app. All Rails integrations also
30
30
  have mixed-in methods for capturing exceptions you've rescued yourself inside of controllers:
31
31
 
32
32
  ```ruby
@@ -39,27 +39,7 @@ have mixed-in methods for capturing exceptions you've rescued yourself inside of
39
39
 
40
40
  #### Delayed::Job
41
41
 
42
- The easiest way of enabling Raven for all your delayed jobs is to use [delayed-plugins-raven](https://github.com/qiushihe/delayed-plugins-raven) gem. First add it to your application's Gemfile:
43
-
44
- ```
45
- gem 'delayed-plugins-raven'
46
- ```
47
-
48
- And then extend your Raven configuration (eg. in ```config/initializers/raven.rb``` file):
49
-
50
- ```ruby
51
- require 'raven'
52
- require 'delayed-plugins-raven'
53
-
54
- Raven.configure do |config|
55
- config.dsn = 'https://public:secret@app.getsentry.com/9999'
56
- ...
57
- end
58
-
59
- Delayed::Worker.plugins << Delayed::Plugins::Raven::Plugin
60
- ```
61
-
62
- For more configuration options check delayed-plugins-raven [documentation](https://github.com/qiushihe/delayed-plugins-raven).
42
+ Reporting errors raised in delayed jobs should work out-of the box. Usage of [delayed-plugins-raven](https://github.com/qiushihe/delayed-plugins-raven) gem is deprecated.
63
43
 
64
44
  ### Rails 2
65
45
 
@@ -11,6 +11,7 @@ require 'raven/interfaces/exception'
11
11
  require 'raven/interfaces/stack_trace'
12
12
  require 'raven/interfaces/http'
13
13
  require 'raven/processors/sanitizedata'
14
+ require 'raven/integrations/delayed_job'
14
15
 
15
16
  module Raven
16
17
  class << self
@@ -10,7 +10,7 @@ module Raven
10
10
 
11
11
  class Client
12
12
 
13
- PROTOCOL_VERSION = '3'
13
+ PROTOCOL_VERSION = '5'
14
14
  USER_AGENT = "raven-ruby/#{Raven::VERSION}"
15
15
  CONTENT_TYPE = 'application/json'
16
16
 
@@ -23,7 +23,7 @@ module Raven
23
23
  PLATFORM = "ruby"
24
24
 
25
25
  attr_reader :id
26
- attr_accessor :project, :message, :timestamp, :level
26
+ attr_accessor :project, :message, :timestamp, :time_spent, :level
27
27
  attr_accessor :logger, :culprit, :server_name, :modules, :extra, :tags
28
28
 
29
29
  def initialize(options = {}, &block)
@@ -35,6 +35,7 @@ module Raven
35
35
  @id = options[:id] || UUIDTools::UUID.random_create.hexdigest
36
36
  @message = options[:message]
37
37
  @timestamp = options[:timestamp] || Time.now.utc
38
+ @time_spent = options[:time_spent]
38
39
 
39
40
  @level = options[:level] || :error
40
41
  @logger = options[:logger] || 'root'
@@ -67,6 +68,7 @@ module Raven
67
68
 
68
69
  # Some type coercion
69
70
  @timestamp = @timestamp.strftime('%Y-%m-%dT%H:%M:%S') if @timestamp.is_a?(Time)
71
+ @time_spent = (@time_spent*1000).to_i if @time_spent.is_a?(Float)
70
72
  @level = LOG_LEVELS[@level.to_s.downcase] if @level.is_a?(String) || @level.is_a?(Symbol)
71
73
  end
72
74
 
@@ -101,6 +103,7 @@ module Raven
101
103
  'event_id' => @id,
102
104
  'message' => @message,
103
105
  'timestamp' => @timestamp,
106
+ 'time_spent' => @time_spent,
104
107
  'level' => @level,
105
108
  'project' => @project,
106
109
  'logger' => @logger,
@@ -111,7 +114,7 @@ module Raven
111
114
  data['modules'] = @modules if @modules
112
115
  data['extra'] = @extra if @extra
113
116
  data['tags'] = @tags if @tags
114
- data['sentry.interfaces.User'] = @user if @user
117
+ data['user'] = @user if @user
115
118
  @interfaces.each_pair do |name, int_data|
116
119
  data[name] = int_data.to_hash
117
120
  end
@@ -138,25 +141,35 @@ module Raven
138
141
  new(options) do |evt|
139
142
  evt.message = "#{exc.class.to_s}: #{exc.message}"
140
143
  evt.level = options[:level] || :error
141
- evt.parse_exception(exc)
142
- if exc.backtrace
143
- evt.interface :stack_trace do |int|
144
- backtrace = Backtrace.parse(exc.backtrace)
145
- int.frames = backtrace.lines.reverse.map do |line|
146
- int.frame do |frame|
147
- frame.abs_path = line.file
148
- frame.function = line.method
149
- frame.lineno = line.number
150
- frame.in_app = line.in_app
151
- if context_lines && frame.abs_path
152
- frame.pre_context, frame.context_line, frame.post_context = \
153
- evt.get_file_context(frame.abs_path, frame.lineno, context_lines)
144
+
145
+ evt.interface(:exception) do |int|
146
+ int.type = exc.class.to_s
147
+ int.value = exc.to_s
148
+ int.module = exc.class.to_s.split('::')[0...-1].join('::')
149
+
150
+ # TODO(dcramer): this needs cleaned up, but I couldn't figure out how to
151
+ # work Hashie as a non-Rubyist
152
+ if exc.backtrace
153
+ int.stacktrace = StacktraceInterface.new do |stacktrace|
154
+ backtrace = Backtrace.parse(exc.backtrace)
155
+ stacktrace.frames = backtrace.lines.reverse.map do |line|
156
+ stacktrace.frame do |frame|
157
+ frame.abs_path = line.file
158
+ frame.function = line.method
159
+ frame.lineno = line.number
160
+ frame.in_app = line.in_app
161
+ if context_lines && frame.abs_path
162
+ frame.pre_context, frame.context_line, frame.post_context = \
163
+ evt.get_file_context(frame.abs_path, frame.lineno, context_lines)
164
+ end
154
165
  end
155
- end
156
- end.select { |f| f.filename }
157
- evt.culprit = evt.get_culprit(int.frames)
166
+ end.select { |f| f.filename }
167
+
168
+ evt.culprit = evt.get_culprit(stacktrace.frames)
169
+ end
158
170
  end
159
171
  end
172
+
160
173
  block.call(evt) if block
161
174
  end
162
175
  end
@@ -187,14 +200,6 @@ module Raven
187
200
  "#{lastframe.filename} in #{lastframe.function} at line #{lastframe.lineno}" if lastframe
188
201
  end
189
202
 
190
- def parse_exception(exception)
191
- interface(:exception) do |int|
192
- int.type = exception.class.to_s
193
- int.value = exception.to_s
194
- int.module = exception.class.to_s.split('::')[0...-1].join('::')
195
- end
196
- end
197
-
198
203
  # For cross-language compat
199
204
  class << self
200
205
  alias :captureException :from_exception
@@ -0,0 +1,51 @@
1
+ if defined?(Delayed)
2
+ require 'delayed_job'
3
+
4
+ module Delayed
5
+ module Plugins
6
+
7
+ class Raven < ::Delayed::Plugin
8
+ callbacks do |lifecycle|
9
+ lifecycle.around(:invoke_job) do |job, *args, &block|
10
+ begin
11
+ # Forward the call to the next callback in the callback chain
12
+ block.call(job, *args)
13
+
14
+ rescue Exception => exception
15
+ # Log error to Sentry
16
+ ::Raven.capture_exception(exception,
17
+ logger => 'delayed_job',
18
+ tags => {
19
+ delayed_job_queue => job.queue
20
+ },
21
+ extra => {
22
+ delayed_job => {
23
+ id => job.id,
24
+ priority => job.priority,
25
+ attempts => job.attempts,
26
+ handler => job.handler,
27
+ last_error => job.last_error,
28
+ run_at => job.run_at,
29
+ locked_at => job.locked_at,
30
+ #failed_at => job.failed_at,
31
+ locked_by => job.locked_by,
32
+ queue => job.queue,
33
+ created_at => job.created_at
34
+ }
35
+ })
36
+
37
+ # Make sure we propagate the failure!
38
+ raise exception
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ end
45
+ end
46
+
47
+ ##
48
+ # Register DelayedJob Raven plugin
49
+ #
50
+ Delayed::Worker.plugins << Delayed::Plugins::Raven
51
+ end
@@ -3,10 +3,19 @@ require 'raven/interfaces'
3
3
  module Raven
4
4
  class ExceptionInterface < Interface
5
5
 
6
- name 'sentry.interfaces.Exception'
6
+ name 'exception'
7
7
  property :type, :required => true
8
8
  property :value, :required => true
9
9
  property :module
10
+ property :stacktrace
11
+
12
+ def to_hash(*args)
13
+ data = super(*args)
14
+ if data['stacktrace']
15
+ data['stacktrace'] = data['stacktrace'].to_hash
16
+ end
17
+ data
18
+ end
10
19
  end
11
20
 
12
21
  register_interface :exception => ExceptionInterface
@@ -3,7 +3,7 @@ require 'raven/interfaces'
3
3
  module Raven
4
4
  class HttpInterface < Interface
5
5
 
6
- name 'sentry.interfaces.Http'
6
+ name 'request'
7
7
  property :url, :required => true
8
8
  property :method, :required => true
9
9
  property :data
@@ -5,7 +5,7 @@ require 'raven/interfaces'
5
5
  module Raven
6
6
  class StacktraceInterface < Interface
7
7
 
8
- name 'sentry.interfaces.Stacktrace'
8
+ name 'stacktrace'
9
9
  property :frames, :default => []
10
10
 
11
11
  def initialize(*arguments)
@@ -1,3 +1,5 @@
1
+ require 'time'
2
+
1
3
  module Raven
2
4
  # Middleware for Rack applications. Any errors raised by the upstream
3
5
  # application will be delivered to Sentry and re-raised.
@@ -19,6 +21,7 @@ module Raven
19
21
  # Use a standard Raven.configure call to configure your server credentials.
20
22
  class Rack
21
23
  def self.capture_exception(exception, env, options = {})
24
+ options[:time_spent] = Time.now-env[:requested_at]
22
25
  Raven.capture_exception(exception, options) do |evt|
23
26
  evt.interface :http do |int|
24
27
  int.from_rack(env)
@@ -27,6 +30,7 @@ module Raven
27
30
  end
28
31
 
29
32
  def self.capture_message(message, env, options = {})
33
+ options[:time_spent] = Time.now-env[:requested_at]
30
34
  Raven.capture_message(message, options) do |evt|
31
35
  evt.interface :http do |int|
32
36
  int.from_rack(env)
@@ -39,8 +43,12 @@ module Raven
39
43
  end
40
44
 
41
45
  def call(env)
46
+ # clear context at the beginning of the request to ensure a clean slate
47
+ Context.clear!
48
+
42
49
  # store the current environment in our local context for arbitrary
43
50
  # callers
51
+ env[:requested_at] = Time.now
44
52
  Raven.rack_context(env)
45
53
 
46
54
  begin
@@ -50,8 +58,6 @@ module Raven
50
58
  rescue Exception => e
51
59
  Raven::Rack.capture_exception(e, env)
52
60
  raise
53
- ensure
54
- Context.clear!
55
61
  end
56
62
 
57
63
  error = env['rack.exception'] || env['sinatra.error']
@@ -1,9 +1,13 @@
1
+ require 'time'
2
+
1
3
  module Raven
2
4
  class Sidekiq
3
5
  def call(worker, msg, queue)
6
+ started_at = Time.now
4
7
  yield
5
8
  rescue => ex
6
- Raven.capture_exception(ex, :extra => { :sidekiq => msg })
9
+ Raven.capture_exception(ex, :extra => { :sidekiq => msg },
10
+ :time_spent => Time.now-started_at)
7
11
  raise
8
12
  end
9
13
  end
@@ -1,3 +1,3 @@
1
1
  module Raven
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentry-raven
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
5
- prerelease:
4
+ version: 0.9.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Noah Kantrowitz
@@ -10,85 +9,106 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2014-04-17 00:00:00.000000000 Z
12
+ date: 2014-05-22 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: faraday
17
- requirement: &70314193748940 !ruby/object:Gem::Requirement
18
- none: false
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  requirements:
20
18
  - - ! '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: 0.7.6
23
21
  type: :runtime
24
22
  prerelease: false
25
- version_requirements: *70314193748940
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ! '>='
26
+ - !ruby/object:Gem::Version
27
+ version: 0.7.6
26
28
  - !ruby/object:Gem::Dependency
27
29
  name: uuidtools
28
- requirement: &70314193747940 !ruby/object:Gem::Requirement
29
- none: false
30
+ requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
32
  - - ! '>='
32
33
  - !ruby/object:Gem::Version
33
34
  version: '0'
34
35
  type: :runtime
35
36
  prerelease: false
36
- version_requirements: *70314193747940
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
37
42
  - !ruby/object:Gem::Dependency
38
43
  name: hashie
39
- requirement: &70314198598820 !ruby/object:Gem::Requirement
40
- none: false
44
+ requirement: !ruby/object:Gem::Requirement
41
45
  requirements:
42
46
  - - ! '>='
43
47
  - !ruby/object:Gem::Version
44
48
  version: 1.1.0
45
49
  type: :runtime
46
50
  prerelease: false
47
- version_requirements: *70314198598820
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: 1.1.0
48
56
  - !ruby/object:Gem::Dependency
49
57
  name: rake
50
- requirement: &70314198598160 !ruby/object:Gem::Requirement
51
- none: false
58
+ requirement: !ruby/object:Gem::Requirement
52
59
  requirements:
53
60
  - - ! '>='
54
61
  - !ruby/object:Gem::Version
55
62
  version: '0'
56
63
  type: :development
57
64
  prerelease: false
58
- version_requirements: *70314198598160
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
59
70
  - !ruby/object:Gem::Dependency
60
71
  name: rspec
61
- requirement: &70314198597480 !ruby/object:Gem::Requirement
62
- none: false
72
+ requirement: !ruby/object:Gem::Requirement
63
73
  requirements:
64
74
  - - ~>
65
75
  - !ruby/object:Gem::Version
66
76
  version: '2.10'
67
77
  type: :development
68
78
  prerelease: false
69
- version_requirements: *70314198597480
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: '2.10'
70
84
  - !ruby/object:Gem::Dependency
71
85
  name: mime-types
72
- requirement: &70314198596820 !ruby/object:Gem::Requirement
73
- none: false
86
+ requirement: !ruby/object:Gem::Requirement
74
87
  requirements:
75
88
  - - ~>
76
89
  - !ruby/object:Gem::Version
77
90
  version: '1.16'
78
91
  type: :development
79
92
  prerelease: false
80
- version_requirements: *70314198596820
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ version: '1.16'
81
98
  - !ruby/object:Gem::Dependency
82
99
  name: coveralls
83
- requirement: &70314198596420 !ruby/object:Gem::Requirement
84
- none: false
100
+ requirement: !ruby/object:Gem::Requirement
85
101
  requirements:
86
102
  - - ! '>='
87
103
  - !ruby/object:Gem::Version
88
104
  version: '0'
89
105
  type: :development
90
106
  prerelease: false
91
- version_requirements: *70314198596420
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
92
112
  description:
93
113
  email: noah@coderanger.net
94
114
  executables:
@@ -98,6 +118,10 @@ extra_rdoc_files:
98
118
  - README.md
99
119
  - LICENSE
100
120
  files:
121
+ - LICENSE
122
+ - README.md
123
+ - bin/raven
124
+ - lib/raven.rb
101
125
  - lib/raven/backtrace.rb
102
126
  - lib/raven/base.rb
103
127
  - lib/raven/cli.rb
@@ -106,11 +130,12 @@ files:
106
130
  - lib/raven/context.rb
107
131
  - lib/raven/error.rb
108
132
  - lib/raven/event.rb
133
+ - lib/raven/integrations/delayed_job.rb
134
+ - lib/raven/interfaces.rb
109
135
  - lib/raven/interfaces/exception.rb
110
136
  - lib/raven/interfaces/http.rb
111
137
  - lib/raven/interfaces/message.rb
112
138
  - lib/raven/interfaces/stack_trace.rb
113
- - lib/raven/interfaces.rb
114
139
  - lib/raven/linecache.rb
115
140
  - lib/raven/logger.rb
116
141
  - lib/raven/okjson.rb
@@ -122,37 +147,33 @@ files:
122
147
  - lib/raven/railtie.rb
123
148
  - lib/raven/sidekiq.rb
124
149
  - lib/raven/tasks.rb
150
+ - lib/raven/transports.rb
125
151
  - lib/raven/transports/http.rb
126
152
  - lib/raven/transports/udp.rb
127
- - lib/raven/transports.rb
128
153
  - lib/raven/version.rb
129
- - lib/raven.rb
130
154
  - lib/sentry-raven.rb
131
- - README.md
132
- - LICENSE
133
- - bin/raven
134
155
  homepage: http://github.com/getsentry/raven-ruby
135
- licenses: []
156
+ licenses:
157
+ - Apache-2.0
158
+ metadata: {}
136
159
  post_install_message:
137
160
  rdoc_options: []
138
161
  require_paths:
139
162
  - lib
140
163
  required_ruby_version: !ruby/object:Gem::Requirement
141
- none: false
142
164
  requirements:
143
165
  - - ! '>='
144
166
  - !ruby/object:Gem::Version
145
167
  version: '0'
146
168
  required_rubygems_version: !ruby/object:Gem::Requirement
147
- none: false
148
169
  requirements:
149
170
  - - ! '>='
150
171
  - !ruby/object:Gem::Version
151
172
  version: '0'
152
173
  requirements: []
153
174
  rubyforge_project:
154
- rubygems_version: 1.8.10
175
+ rubygems_version: 2.2.2
155
176
  signing_key:
156
- specification_version: 3
177
+ specification_version: 4
157
178
  summary: A gem that provides a client interface for the Sentry error logger
158
179
  test_files: []