This document shows examples of how to configure attribute collection with the New Relic Ruby agent. For a list of all Ruby agent config settings for attributes, see Ruby agent configuration: Attributes.
Capture request parameters
Capturing request parameters is not enabled by default. The following configuration will turn on parameter capture for the default destinations: transaction_tracer
, transaction_events
, and error_collector
. To limit the destinations see the Selecting specific destinations example.
Configuration:
attributes.include: request.parameters.*
Request parameters are prefixed with the string request.parameters
, and nested parameters have keys to reflect that nesting. For example, a user with a location attribute nested below a profile would have a key ofrequest.parameters.user.profile.location
.
Similarly, attributes that are members of collections will have keys with indices that reflect the membership. If a user had multiple phone numbers, keys would appear as follows: request.parameters.phone_numbers.0
, request.parameters.phone_numbers.1
, etc.
Exclude sensitive data while capturing request parameters
There may be situations where you would like to omit sensitive information from request parameters, such as passwords or credit card numbers. The following configuration will accomplish that:
Configuration:
attributes.include: request.parameters.*attributes.exclude: [request.parameters.password, request.parameters.credit_card_no]
Capture only specific request parameters
To capture only specific request parameters, you can simply pass a list to attributes.include
:
Configuration:
attributes.include: [request.parameters.user_id, request.parameters.shard_id]
Capture Resque job arguments
By default Resque job arguments are not captured. To enable this functionality use the configuration below.
attributes.include: job.resque.args.*
Note:
Arguments to Resque jobs are positional and the keys generated reflect this. For example a job that takes two arguments will have keys job.resque.args.0
and job.resque.args.1
Capture Sidekiq job arguments
By default Sidekiq job arguments are not captured. To enable this functionality use the configuration below.
attributes.include: job.sidekiq.args.*
Note:
Arguments to Sidekiq jobs are positional and the keys generated reflect this. For example a job that takes two arguments will have keys job.sidekiq.args.0
and job.sidekiq.args.1
Disabling all attributes
In this example, attributes are disabled, so the include and exclude lists will be ignored and all attributes will be filtered out.
Configuration:
attributes.enabled: falseattributes.include: request.parameters.*
Input keys:
foo, bar, request.parameters.foo, request.parameters.bar
Output for destinations:
- transaction_tracer: none
- error_collector: none
- transaction_events: none
- browser_monitoring: none
Selecting specific destinations
In this example:
- Attributes are disabled for transaction traces. The include and exclude lists will be ignored, and all attributes will be filtered out for this destination.
- Attributes are also disabled for by default.
- Request parameters (prefixed with
request.parameters.
) are off by default for all destinations.
As a result, only bar
is sent in traced errors and transaction events.
Configuration:
attributes.enabled: truetransaction_tracer.attributes.enabled: falseattributes.exclude: foo
Input keys:
foo, bar, request.parameters.foo, request.parameters.bar
Output for destinations:
- transaction_tracer: none
- error_collector: bar
- transaction_events: bar
- browser_monitoring: none
Selecting values and destinations
In this example, specific input keys are selected for certain output destinations and excluded from others.
- The
food.fruit.banana
key will be excluded only from transaction traces. - The
food
andfood.vegetable
keys will be excluded from all destinations.
Configuration:
browser_monitoring.attributes.enabled: trueattributes.exclude: food*attributes.include: food.fruit.*transaction_tracer.attributes.exclude: food.fruit.banana
Input keys:
food, food.vegetable, food.fruit.apple, food.fruit.banana
Output for destinations:
- transaction_tracer: food.fruit.apple
- error_collector: food.fruit.apple, food.fruit.banana
- transaction_events: food.fruit.apple, food.fruit.banana
- browser_monitoring: food.fruit.apple, food.fruit.banana