Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filtering capabilities for Sidekiq job argument collection #2150

Closed
hannahramadan opened this issue Aug 3, 2023 · 6 comments · Fixed by #2177
Closed

Add filtering capabilities for Sidekiq job argument collection #2150

hannahramadan opened this issue Aug 3, 2023 · 6 comments · Fixed by #2177
Assignees
Labels
2 Story Point Estimate feature request To tag feature request after Hero Triage for PM to disposition

Comments

@hannahramadan
Copy link
Contributor

hannahramadan commented Aug 3, 2023

The agent's Sidekiq instrumentation has the ability to capture Sidekiq job arguments, which become attributes on transaction traces and traced errors. By default, this configuration option is turned off in case job arguments contain sensitive information (docs). This feature can be turned on by adding the string job.sidekiq.args.* to the attributes.include array inside newrelic.yml.

The current implementation offers an all-or-nothing approach—either all job arguments are captured or none are. job.sidekiq.args.* is the only Sidekiq-related value that attributes.include respects, and any added to attributes.exclude are ignored.

perform_action_with_newrelic_trace(trace_args) do
NewRelic::Agent::Transaction.merge_untrusted_agent_attributes(msg['args'], :'job.sidekiq.args',
NewRelic::Agent::AttributeFilter::DST_NONE)
::NewRelic::Agent::DistributedTracing::accept_distributed_trace_headers(trace_headers, 'Other') if ::NewRelic::Agent.config[:'distributed_tracing.enabled'] && trace_headers&.any?
yield

We should explore adding more advanced filtering capabilities to give customers greater control over which Sidekiq job arguments should or shouldn't be collected.

@hannahramadan hannahramadan added the feature request To tag feature request after Hero Triage for PM to disposition label Aug 3, 2023
@workato-integration
Copy link

@hannahramadan hannahramadan added the 2 Story Point Estimate label Aug 8, 2023
@kford-newrelic kford-newrelic added estimate Issue needing estimation and removed estimate Issue needing estimation labels Aug 9, 2023
@fallwith fallwith self-assigned this Aug 14, 2023
@fallwith fallwith linked a pull request Aug 28, 2023 that will close this issue
@fallwith
Copy link
Contributor

The capabilities requested will be available in the next agent release.

@fallwith
Copy link
Contributor

The changes delivered by #2177 are now generally available in v9.5.0 of the Ruby agent available for download from RubyGems.org.

@lcmen
Copy link

lcmen commented Sep 13, 2023

@fallwith thank you for this. Quick question: with this new feature in place, does attributes.exclude support regex expressions the same way as sidekiq.args.exclude?

I would like to exclude sending sensitive parameters (e.g. request.parameters.user.password, request.parameters.employee.password, etc.) with single regex. However exclude option with request.parameters.*password$ does not work for me on the latest release. (documentation mentions only wildcard support like request.parameters.users.*).

@fallwith
Copy link
Contributor

@fallwith thank you for this. Quick question: with this new feature in place, does attributes.exclude support regex expressions the same way as sidekiq.args.exclude?

I would like to exclude sending sensitive parameters (e.g. request.parameters.user.password, request.parameters.employee.password, etc.) with single regex. However exclude option with request.parameters.*password$ does not work for me on the latest release. (documentation mentions only wildcard support like request.parameters.users.*).

Hi @lcmen. The attributes.exclude functionality was not updated with the new v9.5.0 gem release, so attributes.exclude continues to only support the wildcard (*) functionality you referenced and not regex.

As of v9.5.0 regex support for filtering is limited to the Ruby specific Sidekiq and Stripe instrumentation. We wanted to be very careful to not alter existing attributes.include and attributes.exclude functionality to avoid breaking compatibility with existing Ruby customer usage and to maintain alignment of their functionality with New Relic agents in other languages for consistency in multilingual environments.

Based on the feedback and usage of the new regex filtering for Sidekiq and Stripe, we may very well bring regex filtering to other parts of the agent. The regex support for those two instrumentations works in conjunction with the attributes.include and attributes.exclude functionality with both filters being respected, so it's possible that we could do something similar in future for request parameters by adding an extra, regex based layer of filtering in the same way.

If you'd like to see that or anything else done with the agent, we welcome feature requests (link: create a feature request) and PRs here in GitHub.

I appreciate your reaching out, thanks!

@lcmen
Copy link

lcmen commented Sep 25, 2023

@fallwith thank you for such detailed explenation. I really appreciate that 🙇 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 Story Point Estimate feature request To tag feature request after Hero Triage for PM to disposition
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants