honeycomb-rails 0.5.1 → 0.6.0

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
  SHA256:
3
- metadata.gz: 5d63f54aff8e75b9dc23176de419708a641c7ffa9feb6acc2ceea77ff9750093
4
- data.tar.gz: 028d64690d7bbdc8bc071b75ae999683c3b28c9fd41406cd30ddaa1a082dbb19
3
+ metadata.gz: 5269a0de1a6d47dd7c0ff92bdd5e2a954369ad0f49b09ca5c23a7c3e1d4d0214
4
+ data.tar.gz: 79a58361d5f1a334f9d58f48be31f13779d243130a7ea74951547baf4147f0c5
5
5
  SHA512:
6
- metadata.gz: 553739e9285b2fd043288f91336d90d782015b465a7f1e2aa8f572ccc3ea425c766508e995c4f591dc9a74c81f327c8c9731c3a2df9bd429a8bb571333e6ec2b
7
- data.tar.gz: 58663a163b9b813cee39dd0bcc64990a238827e87cc331d74216a702eb38e7a03653bdfb92e4e0fef8560c0fb6db096c2da05c90a568467fe3d7d3c442737de7
6
+ metadata.gz: 396f9cc14e318d1795a4883b54f1906a08692d98d6040219cf1726adb418fc4793c504859da5113e2a81f9fd18a12c89e2b8b87e2ef598d90714fbac61dddeee
7
+ data.tar.gz: d472468f60e3d33fffa15b31b259edb1fdcbc0d08462a0eaf5853c61ec2cfae05b742134ab16e96ff061c0519c25c8cc1f6adfec304fdd68ce3d85fd84c434c2
@@ -8,7 +8,6 @@ module HoneycombRails
8
8
  @db_dataset = 'active_record'
9
9
  @record_flash = true
10
10
  @record_user = :detect
11
- @logger = Rails.logger
12
11
  @capture_exceptions = true
13
12
  @capture_exception_backtraces = true
14
13
  @sample_rate = 1
@@ -81,24 +81,5 @@ module HoneycombRails
81
81
  end
82
82
  end
83
83
  end
84
- module ActionControllerFilters
85
- def self.included(controller_class)
86
- controller_class.around_action :honeycomb_attach_exception_metadata
87
- end
88
-
89
- def honeycomb_attach_exception_metadata
90
- begin
91
- yield
92
- rescue StandardError => exception
93
- honeycomb_metadata[:exception_class] = exception.class.to_s
94
- honeycomb_metadata[:exception_message] = exception.message
95
- if HoneycombRails.config.capture_exception_backtraces
96
- honeycomb_metadata[:exception_source] = Rails.backtrace_cleaner.clean(exception.backtrace)
97
- end
98
-
99
- raise
100
- end
101
- end
102
- end
103
84
  end
104
85
  end
@@ -17,6 +17,8 @@ module HoneycombRails
17
17
  # set up libhoney after application initialization so that any config in
18
18
  # the app's config/initializers has taken effect.
19
19
  config.after_initialize do
20
+ HoneycombRails.config.logger ||= ::Rails.logger
21
+
20
22
  writekey = HoneycombRails.config.writekey
21
23
  if writekey.blank?
22
24
  HoneycombRails.config.logger.warn("No write key defined! (Check your config's `writekey` value in config/initializers/honeycomb.rb) No events will be sent to Honeycomb.")
@@ -26,10 +28,6 @@ module HoneycombRails
26
28
  writekey: writekey,
27
29
  user_agent_addition: HoneycombRails::USER_AGENT_SUFFIX,
28
30
  )
29
-
30
- if HoneycombRails.config.capture_exceptions
31
- ::ActionController::Base.include(Overrides::ActionControllerFilters)
32
- end
33
31
  end
34
32
 
35
33
  config.after_initialize do
@@ -21,13 +21,42 @@ module HoneycombRails
21
21
 
22
22
  # These are the keys we're interested in! Skipping noisy keys (:headers, :params) for now.
23
23
  data = event.payload.slice(:controller, :action, :method, :path, :format,
24
- :status, :db_runtime, :view_runtime)
24
+ :status, :db_runtime, :view_runtime,
25
+ :exception, :exception_object)
25
26
 
26
27
  # Massage data to return "all" as the :format if not set
27
28
  if !data[:format] || data[:format] == "format:*/*"
28
29
  data[:format] = "all"
29
30
  end
30
31
 
32
+ # strip off exception fields for more friendly formatting
33
+ exception_info = data.delete(:exception)
34
+ exception = data.delete(:exception_object)
35
+
36
+ if exception_info
37
+ exception_class, exception_message = exception_info
38
+
39
+ # Apparently these notifications don't include the `status` field if
40
+ # an exception occurred while handling the request, even though the
41
+ # response certainly does end up with a status code set. We'd like to
42
+ # report that status code, so we reuse the same status code lookup
43
+ # table that ActionController uses. This looks janky, but it's how the
44
+ # standard Rails logging does it too... :|
45
+ #
46
+ # https://github.com/rails/rails/blob/37b373a8d2a1cd132bbde51cd5a3abd4ecee433b/actionpack/lib/action_controller/log_subscriber.rb#L27
47
+ data[:status] ||= ActionDispatch::ExceptionWrapper.status_code_for_exception(exception_class)
48
+
49
+ if HoneycombRails.config.capture_exceptions
50
+ data[:exception_class] = exception_class
51
+ data[:exception_message] = exception_message
52
+
53
+ if exception && HoneycombRails.config.capture_exception_backtraces
54
+ data[:exception_source] = ::Rails.backtrace_cleaner.clean(exception.backtrace)
55
+ end
56
+
57
+ end
58
+ end
59
+
31
60
  # Pull top-level attributes off of the ActiveSupport Event.
32
61
  data[:duration_ms] = event.duration
33
62
 
@@ -1,7 +1,7 @@
1
1
  module HoneycombRails
2
2
  GEM_NAME = 'honeycomb-rails'
3
3
 
4
- VERSION = '0.5.1'
4
+ VERSION = '0.6.0'
5
5
 
6
6
  USER_AGENT_SUFFIX = "#{GEM_NAME}/#{VERSION}".freeze
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeycomb-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stokes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-04-11 00:00:00.000000000 Z
12
+ date: 2018-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: libhoney