Regex support for ActiveSupport::Notfications integration
Closed this issue · 2 comments
ajvondrak commented
With ActiveSupport notifications, you can use a regular expression to subscribe to events en masse [ref]:
ActiveSupport::Notifications.subscribe /regex/ do |*args|
# events matching /regex/ are handled here
end
However, trying to use regular expressions in the Honeycomb configuration breaks:
Honeycomb.configure do |config|
config.notification_events = [/regex/]
end
ActiveSupport::Notifications.instrument 'string_matching_regex'
#=> Exception: NoMethodError: undefined method `call' for nil:NilClass
What's happening is that
just populates thehandlers
using the regex as the key:
handlers[/regex/] = block
But ActiveSupport will pass the exact event name string to the subscriber, so
will try to invoke the handler likehandlers['string_matching_regex'].call
which of course blows up.
This isn't as much of a bug as it is a feature request. We don't necessarily have to support regexes, but it'd be more consistent with the ActiveSupport::Notifications.subscribe
interface.
martin308 commented
This is a great suggestion, I think I'll leave it as a feature request for now unless you want to take it on?