Skip to content

feat(data-collection): Port Rails log subscriber #3034

Open
sl0thentr0py wants to merge 2 commits into
neel/data-collection/railsfrom
neel/data-collection/rails-logs
Open

feat(data-collection): Port Rails log subscriber #3034
sl0thentr0py wants to merge 2 commits into
neel/data-collection/railsfrom
neel/data-collection/rails-logs

Conversation

@sl0thentr0py

@sl0thentr0py sl0thentr0py commented Jul 23, 2026

Copy link
Copy Markdown
Member
  • Remove ParameterFilter usage completely
  • Nested payloads will now not be scrubbed (we will revisit this later if necessary)

Stack created with GitHub Stacks CLIGive Feedback 💬

Issues

* Rails controller span data query inclusion is modified to comply with URL collection spec.
* Rails `filter_parameters` are backfilled into `url_query_params`
  * Allow regexes in `terms` as a result to enable this
@linear-code

linear-code Bot commented Jul 23, 2026

Copy link
Copy Markdown

RUBY-194

* Remove `ParameterFilter` usage completely
* Nested payloads will now **not** be scrubbed (we will revisit this later if necessary)
@sl0thentr0py
sl0thentr0py force-pushed the neel/data-collection/rails-logs branch from d8a5cd0 to f24bdc4 Compare July 23, 2026 14:35

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f24bdc4. Configure here.

# @return [Hash] a new filtered hash, or an empty hash when collection is off
def filter(values, cookie: false)
return {} if mode == :off
return {} unless values.is_a?(Hash)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hash guard drops Parameters

High Severity

The new is_a?(Hash) guard in filter rejects ActionController::Parameters, which has not inherited from Hash since Rails 5. controller_transaction passes request.params into this method, so span params become {} whenever query-param collection is enabled.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f24bdc4. Configure here.


filter_parameters = ::Rails.application.config.filter_parameters
collection.terms = Array(collection.terms) + Array(filter_parameters)
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate filter param merge

Medium Severity

New configure_data_collection re-merges Rails filter_parameters into url_query_params.terms, but configuration.rb already does this in after(:configured). The railtie copy also skips type filtering and uniq, so procs can become junk terms and valid terms are duplicated.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f24bdc4. Configure here.

else
argument
end
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Queues gated by query filter

Medium Severity

Job argument inclusion is gated by data_collection.queues, but Hash arguments are passed through url_query_params.filter. When queues is on and url_query_params.mode is :off, that filter returns {}, so hash arguments are dropped even though queue data collection is enabled.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f24bdc4. Configure here.

def configure_data_collection
collection = Sentry.configuration.data_collection.url_query_params
return unless collection.mode == :deny_list

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The new configure_data_collection method adds filter_parameters to collection.terms a second time, creating duplicates and adding invalid Proc objects as garbage strings.
Severity: LOW

Suggested Fix

Remove the new configure_data_collection method and its call from the config.after_initialize block. The existing after(:configured) callback in sentry/rails/configuration.rb already handles adding filter_parameters correctly, including filtering for Proc objects and deduplicating the list.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: sentry-rails/lib/sentry/rails/railtie.rb#L89

Potential issue: The new `configure_data_collection` method, called during
`config.after_initialize`, appends `Rails.application.config.filter_parameters` to
`Sentry.configuration.send_default_pii_collection.terms`. This duplicates an existing
`after(:configured)` callback that already performs this action during `Sentry.init`.
The new implementation lacks the filtering present in the original, causing `Proc`
objects to be converted to useless strings like `"#<proc:0x...>"`. This results in a
bloated `terms` list containing both duplicate valid parameters and permanent, invalid
entries, though it does not affect filtering correctness.

Also affects:

  • sentry-rails/lib/sentry/rails/configuration.rb:37

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(pii): Wire Rails log-subscriber data (active_record, mailer, active_job)

1 participant