Skip to content

Commit

Permalink
sl0thentr0py suggestion's
Browse files Browse the repository at this point in the history
  • Loading branch information
igordepolli committed Oct 23, 2023
1 parent 60ec58e commit a0c92b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Features

- Add new `config.rails.active_support_logger_subscription_items` to allow customization breadcrumb data of active support logger
- Add new `config.rails.active_support_logger_subscription_items` to allow customization breadcrumb data of active support logger [#2139](https://github.com/getsentry/sentry-ruby/pull/2139)

```rb
config.rails.active_support_logger_subscription_items["sql.active_record"] << :type_casted_binds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ def add(name, started, _finished, _unique_id, data)
# skip Rails' internal events
return if name.start_with?("!")

allowed_keys = Sentry.configuration.rails.active_support_logger_subscription_items[name]

if data.is_a?(Hash)
data = data.slice(*allowed_keys)
data = data.slice(*@allowed_keys[name])
end

crumb = Sentry::Breadcrumb.new(
Expand All @@ -21,7 +19,9 @@ def add(name, started, _finished, _unique_id, data)
Sentry.add_breadcrumb(crumb)
end

def inject
def inject(allowed_keys)
@allowed_keys = allowed_keys

@subscriber = ::ActiveSupport::Notifications.subscribe(/.*/) do |name, started, finished, unique_id, data|
# we only record events that has a started timestamp
if started.is_a?(Time)
Expand Down
2 changes: 1 addition & 1 deletion sentry-rails/lib/sentry/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def patch_background_worker
def inject_breadcrumbs_logger
if Sentry.configuration.breadcrumbs_logger.include?(:active_support_logger)
require 'sentry/rails/breadcrumb/active_support_logger'
Sentry::Rails::Breadcrumb::ActiveSupportLogger.inject
Sentry::Rails::Breadcrumb::ActiveSupportLogger.inject(Sentry.configuration.rails.active_support_logger_subscription_items)
end

if Sentry.configuration.breadcrumbs_logger.include?(:monotonic_active_support_logger)
Expand Down

0 comments on commit a0c92b6

Please sign in to comment.