honeycomb-rails 0.3.0 → 0.4.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ce38870b1d7d5dc68b425b3e4bf323ea3e26b4d59b2bad85270b17f4f444b2e
|
4
|
+
data.tar.gz: 8f30aa96990892d0cb6515b119bff5aac96045e1b9fc1bb1137febd72b7ac91a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca245585297cb2f654828cf2729b064a174c13187023dfdd9b113c793ad39dd0084edb065a6476e75fd35bd5d8c36e08527065d3b48a8887b8fdf8a4fa89d1a6
|
7
|
+
data.tar.gz: ee159ce39880ac7438fb904d5d8600d824df005fce2d42002bc63d934f8e861f9bc84047a6c5046f3122ebb594bada4128e73c8912377f89038d76f97bb6f50d
|
@@ -9,6 +9,9 @@ module HoneycombRails
|
|
9
9
|
@record_flash = true
|
10
10
|
@record_user = :detect
|
11
11
|
@logger = Rails.logger
|
12
|
+
@capture_exceptions = true
|
13
|
+
@capture_exception_backtraces = true
|
14
|
+
@sample_rate = 1
|
12
15
|
end
|
13
16
|
|
14
17
|
# Whether to record flash messages (default: true).
|
@@ -45,6 +48,27 @@ module HoneycombRails
|
|
45
48
|
|
46
49
|
# The Honeycomb write key for your team (must be specified).
|
47
50
|
attr_accessor :writekey
|
51
|
+
|
52
|
+
# If set, determines how to record the sample rate for a given Honeycomb
|
53
|
+
# event. (default: 1, do not sample)
|
54
|
+
#
|
55
|
+
# Valid values:
|
56
|
+
# * Integer - sample Honeycomb events at a constant rate
|
57
|
+
# * 1 or lower - disable sampling on this dataset; capture all events
|
58
|
+
# * TODO: :rails - default Rails dynamic sampling?
|
59
|
+
#
|
60
|
+
# You can also pass a Proc, which will be called with the current controller
|
61
|
+
# instance during each request, and which should return a sample rate for
|
62
|
+
# the request in question.
|
63
|
+
attr_accessor :sample_rate
|
64
|
+
|
65
|
+
# If set to true, captures exception class name / message along with Rails
|
66
|
+
# request events. (default: true)
|
67
|
+
attr_accessor :capture_exceptions
|
68
|
+
|
69
|
+
# If set to true, captures backtraces when capturing exception metadata.
|
70
|
+
# No-op if capture_exceptions is false. (default: true)
|
71
|
+
attr_accessor :capture_exception_backtraces
|
48
72
|
end
|
49
73
|
|
50
74
|
class << self
|
@@ -65,5 +65,24 @@ module HoneycombRails
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
68
|
+
module ActionControllerFilters
|
69
|
+
def self.included(controller_class)
|
70
|
+
controller_class.around_action :honeycomb_attach_exception_metadata
|
71
|
+
end
|
72
|
+
|
73
|
+
def honeycomb_attach_exception_metadata
|
74
|
+
begin
|
75
|
+
yield
|
76
|
+
rescue StandardError => exception
|
77
|
+
honeycomb_metadata[:exception_class] = exception.class.to_s
|
78
|
+
honeycomb_metadata[:exception_message] = exception.message
|
79
|
+
if HoneycombRails.config.capture_exception_backtraces
|
80
|
+
honeycomb_metadata[:exception_source] = Rails.backtrace_cleaner.clean(exception.backtrace)
|
81
|
+
end
|
82
|
+
|
83
|
+
raise
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
68
87
|
end
|
69
88
|
end
|
@@ -19,6 +19,10 @@ module HoneycombRails
|
|
19
19
|
config.after_initialize do
|
20
20
|
writekey = HoneycombRails.config.writekey
|
21
21
|
@libhoney = Libhoney::Client.new(writekey: writekey)
|
22
|
+
|
23
|
+
if HoneycombRails.config.capture_exceptions
|
24
|
+
::ActionController::Base.include(Overrides::ActionControllerFilters)
|
25
|
+
end
|
22
26
|
end
|
23
27
|
|
24
28
|
config.after_initialize do
|
@@ -37,7 +37,19 @@ module HoneycombRails
|
|
37
37
|
data.merge!(event.payload[Constants::EVENT_METADATA_KEY])
|
38
38
|
end
|
39
39
|
|
40
|
-
@libhoney.
|
40
|
+
honeycomb_event = @libhoney.event
|
41
|
+
honeycomb_event.add(data)
|
42
|
+
|
43
|
+
case HoneycombRails.config.sample_rate
|
44
|
+
when Proc
|
45
|
+
honeycomb_event.sample_rate = HoneycombRails.config.sample_rate.call(event.payload)
|
46
|
+
when Integer
|
47
|
+
if HoneycombRails.config.sample_rate > 1
|
48
|
+
honeycomb_event.sample_rate = HoneycombRails.config.sample_rate
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
honeycomb_event.send
|
41
53
|
end
|
42
54
|
end
|
43
55
|
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.
|
4
|
+
version: 0.4.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: 2017-12-
|
12
|
+
date: 2017-12-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: libhoney
|