class Honeybadger::Plugins::RailsBreadcrumbs
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/honeybadger/plugins/breadcrumbs.rbs class Honeybadger::Plugins::RailsBreadcrumbs def self.send_breadcrumb_notification: (String name, Float duration, Hash notification_config, ?Hash data) -> Honeybadger::Agent? end
def self.send_breadcrumb_notification(name, duration, notification_config, data = {})
Experimental RBS support (using type sampling data from the type_fusion
project).
type Honeybadger__Plugins__RailsBreadcrumbs_send_breadcrumb_notification_data = sql | String | name | String | duration | Float | sql | String | name | NilClass | duration | Float | sql | String | name | String | binds | | type_casted_binds | | statement_name | NilClass | async | FalseClass | connection | ActiveRecord::ConnectionAdapters::PostgreSQLAdapter | sql | String | name | String | cached | TrueClass | duration | Float | identifier | String | layout | NilClass | locals | date | Date | group | Group | min_height | String | cache_hit | NilClass | duration | Float def self.send_breadcrumb_notification: (String name, Float duration, (message | Proc | category | String | select_keys | Symbol | Symbol | Symbol | Symbol | transform | Proc | exclude_when | Proc | message | String | category | String) notification_config, ?Honeybadger__Plugins__RailsBreadcrumbs_send_breadcrumb_notification_data data) -> Honeybadger::Agent?
This signature was generated using 72 samples from 1 application.
(**notification_config)
-
:transform
(Proc
) -- A proc that accepts the data payload. The return value will replace the current data hash (optional) -
:exclude_when
(Proc
) -- A proc that accepts the data payload. A truthy return value will exclude this event from the payload (optional) -
:select_keys
(Array
) -- A set of keys that filters what data we select from the instrumentation data (optional) -
:category
(Symbol
) -- A key to group specific types of events -
:message
(String | Proc
) -- A message that describes the event. You can dynamically build the message by passing a proc that accepts the event metadata.
Parameters:
-
data
(Hash
) -- Custom metadata from the instrumentation event -
notification_config
(Hash
) -- The instrumentation event configuration -
duration
(Number
) -- The time spent in the instrumentation event -
name
(String
) -- The ActiveSupport instrumentation key
Other tags:
- Api: - private
def self.send_breadcrumb_notification(name, duration, notification_config, data = {}) return if notification_config[:exclude_when] && notification_config[:exclude_when].call(data) message = case (m = notification_config[:message]) when Proc m.call(data) when String m else name end data = data.slice(*notification_config[:select_keys]) if notification_config[:select_keys] data = notification_config[:transform].call(data) if notification_config[:transform] data = data.is_a?(Hash) ? data : {} data[:duration] = duration if duration Honeybadger.add_breadcrumb( message, category: notification_config[:category] || :custom, metadata: data ) end
def self.subscribe_to_notification(name, notification_config)
- Api: - private
def self.subscribe_to_notification(name, notification_config) ActiveSupport::Notifications.subscribe(name) do |_, started, finished, _, data| duration = finished - started if finished && started send_breadcrumb_notification(name, duration, notification_config, data) end end