The Bearer Agent allows you to update the configuration in your code using the following syntax after installing and requiring the bearer-agent
gem:
Bearer.init_config do |config|config.secret_key = "YOUR_BEARER_SECRET_KEY" # Required, string: Your Bearer private keyconfig.disabled = false # Optional, boolean: enable/disable Bearer globallyend
The following is a list of all available configuration options.
Property | Value |
config.secret_key | Your Bearer Secret Key (required) |
config.disabled | When set, the Bearer agent is disabled |
config.environment | Sets the name of the environment to be used in the dashboard. See below for details. |
config.strip_sensitive_data | Remove sensitive data before sending it to bearer.sh (defaults to |
config.strip_sensitive_keys | Regular expression used for key name values to strip (see defaults) |
config.strip_sensitive_regex | Regular expression used for value stripping (see defaults) |
hook_mode | Select between |
hook_conflict_detection_max_depth | Sets the max recursive attempts the hook method will make. Learn more below. (defaults to 10) |
For more on using the strip_sensitive_data
, strip_sensitive_keys
, and strip_sensitive_regex
configuration properties see Keep your Data Protected.
Bearer uses your application's environment variable or the configuration to determine the environments that exist for an application in the Bearer Dashboard. For Ruby, Bearer will look for any of the following environment variables to determine the name:
RUBY_ENV
RAILS_ENV
RACK_ENV
APP_ENV
If the config.environment
is set in your agent configuration, it will override any of the above ENV names. If no environment name can be detected through environment variables or the configuration, the environment will be set to development
.
The Bearer Agent intercepts HTTP request by hooking into the HTTP clients your application uses. This is done by replacing the HTTP methods with instrumented versions that handle its internal logic, then call the original method. When combined with some gems that use a similar approach, you may experience a BearerAgent::Interceptor::ConflictDetector::Error
exception type. Hook mode helps alleviate and avoid this problem. You can read our full explaination into why this happens and the steps we've taken to resolve it over on our engineering blog, but for most users changing to the alternative mode (to :alias
from the default:prepend
) should resolve any issues.
The hook_conflict_detection_max_depth
setting can help if you're experiencing too many recursive retries. This shouldn't be necessary for most users, but if you're experiencing too many stack traces when a conflict error is raised, changing this value should help resolve the problem.