honeycomb-beeline 2.5.0 → 2.6.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
  SHA256:
3
- metadata.gz: 8dfad7bddebd49b8645b61389e74035626a0cc817d5fc7ea9e51ab17cb571584
4
- data.tar.gz: eadf7a28b41ddb6437e0e5a2c0824c2a2cf67fbf36a95bc18f77ad03b4f74306
3
+ metadata.gz: 4ae074f65cd2b6319b74e07b06148e9e2cd446bfd3fc7c2c686c9ab4702550a4
4
+ data.tar.gz: a7c934d59de13e4099636470fb9660520478bbe56c38c5eb42c69839cb6a6f4a
5
5
  SHA512:
6
- metadata.gz: 7c6204f46a27e4a3af3bf5d2d173fdb4d06f820ecf76dd2ed84d0de52aca83fb155190075b244ee6ab7e811c93927874ae51d36cc117b018de995ad5aeb76f40
7
- data.tar.gz: 175c355b5a5833bfd68b17a281fc2d71f0321f7c708e339b03090b367d64d7a6c9294ed8afcc84d5f538b6c80644f9c26488475962903a2364bb6ab0e7ee93f8
6
+ metadata.gz: 12c63d47f117a7fae5771b504ff58191627824618c7127257ca29f9c0e1de9cee3e140184bf3e04935846a2a9cef6768245ce6a89d540a1e48b8ddd1eb923704
7
+ data.tar.gz: 599d93dc3ca17e34b4828cf557aa98a4b697a26cfffa8957a4b25997c37d7967ab2753bcc01ced943db8e74a52f6dff0f93c0a51ee59d28b0fbc9ad1f144a30b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # beeline-ruby changelog
2
2
 
3
+ ## 2.6.0 2021-07-23
4
+
5
+ ### Added
6
+
7
+ - Allow setting different notification handling logic for specific events (#152) | [@lirossarvet](https://github.com/lirossarvet)
8
+
3
9
  ## 2.5.0 2021-07-16
4
10
 
5
11
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- honeycomb-beeline (2.5.0)
4
+ honeycomb-beeline (2.6.0)
5
5
  libhoney (~> 1.14, >= 1.14.2)
6
6
 
7
7
  GEM
@@ -3,7 +3,7 @@
3
3
  module Honeycomb
4
4
  module Beeline
5
5
  NAME = "honeycomb-beeline".freeze
6
- VERSION = "2.5.0".freeze
6
+ VERSION = "2.6.0".freeze
7
7
  USER_AGENT_SUFFIX = "#{NAME}/#{VERSION}".freeze
8
8
  end
9
9
  end
@@ -8,12 +8,13 @@ module Honeycomb
8
8
  # Included in the configuration object to specify events that should be
9
9
  # subscribed to
10
10
  module Configuration
11
- attr_accessor :notification_events
11
+ attr_writer :notification_events
12
12
 
13
13
  def after_initialize(client)
14
14
  super(client) if defined?(super)
15
15
 
16
- events = notification_events || []
16
+ events = notification_events | active_support_handlers.keys
17
+
17
18
  ActiveSupport::Subscriber.new(client: client).tap do |sub|
18
19
  events.each do |event|
19
20
  sub.subscribe(event, &method(:handle_notification_event))
@@ -21,18 +22,30 @@ module Honeycomb
21
22
  end
22
23
  end
23
24
 
24
- def on_notification_event(&hook)
25
- if block_given?
26
- @on_notification_event = hook
25
+ def on_notification_event(event_name = nil, &hook)
26
+ if event_name
27
+ active_support_handlers[event_name] = hook
27
28
  else
28
- @on_notification_event
29
+ @default_handler = hook
29
30
  end
30
31
  end
31
32
 
32
33
  def handle_notification_event(name, span, payload)
33
- if on_notification_event
34
- on_notification_event.call(name, span, payload)
35
- else
34
+ handler = active_support_handlers.fetch(name, default_handler)
35
+
36
+ handler.call(name, span, payload)
37
+ end
38
+
39
+ def active_support_handlers
40
+ @active_support_handlers ||= {}
41
+ end
42
+
43
+ def notification_events
44
+ @notification_events ||= []
45
+ end
46
+
47
+ def default_handler
48
+ @default_handler ||= lambda do |name, span, payload|
36
49
  payload.each do |key, value|
37
50
  # Make ActionController::Parameters parseable by libhoney.
38
51
  value = value.to_unsafe_hash if value.respond_to?(:to_unsafe_hash)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeycomb-beeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Holman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-16 00:00:00.000000000 Z
11
+ date: 2021-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libhoney