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

Reference upstream docs on instrumentation env vars #147

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 4 additions & 37 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,55 +77,22 @@ ruby application.rb

### Instrumentation Environment Variables

You can use OpenTelemetry Ruby instrumentation environment variables to disable certain instrumentation.
From [instrumentation-base](https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/opentelemetry-instrumentation-base/v0.22.3/instrumentation/base/lib/opentelemetry/instrumentation/base.rb#L56-L61):
> The instrumention class establishes a convention for disabling an instrumentation
> by environment variable and local configuration. An instrumentation disabled
> by environment variable will take precedence over local config. The
> convention for environment variable name is the library name, upcased with
> '::' replaced by underscores, OPENTELEMETRY shortened to OTEL_{LANG}, and '_ENABLED' appended.
> For example: OTEL_RUBY_INSTRUMENTATION_SINATRA_ENABLED = false.
You can use OpenTelemetry Ruby instrumentation environment variables to [disable](https://opentelemetry.io/docs/languages/ruby/libraries/#overriding-configuration-for-specific-instrumentation-libraries-with-environment-variables) or [configure](https://opentelemetry.io/docs/languages/ruby/libraries/#configuring-specific-instrumentation-libraries-with-environment-variables) certain instrumentation, see the [OpenTelemetry Docs](https://opentelemetry.io/docs/languages/ruby/libraries/#use-instrumentation-libraries) for details.

For example to disable sinatra instrumentation, you can set `OTEL_RUBY_INSTRUMENTATION_SINATRA_ENABLED` to false through
For example, to disable sinatra instrumentation and disable mysql2 instrumentation's obfuscation of db.statement:

```bash
export OTEL_RUBY_INSTRUMENTATION_SINATRA_ENABLED=false
```

or in your initialization step

```ruby
ENV['OTEL_RUBY_INSTRUMENTATION_SINATRA_ENABLED']='false'
```

Options setup through enviromental variables

> Checks to see if user pass any environment variable that set option for instrumentation.
> By convention, the environment variable will be the instrumentation name upper cased,
> with '::' replaced by underscores, OPENTELEMETRY shortened to OTEL_{LANG} and_CONFIG_OPTS appended.
> For example, the, environment variable name for OpenTelemetry::Instrumentation::Faraday
> will be OTEL_RUBY_INSTRUMENTATION_FARADAY_CONFIG_OPTS. A value of 'peer_service=new_service;'
> will overrides the option set from ::OpenTelemetry::SDK.configure do |c| ... end for faraday.
>
> For array option, simply separate the value by , (e.g. option=a,b,c,d).
> For boolean option, set value by true or false (e.g. option=true).
> For integer, string, enum, set value by string (e.g. option=string).
> Callable option is not allowed to set through environment variable.

For example, to disable db.statement obfuscation in mysql2 instrumentation, set `OTEL_RUBY_INSTRUMENTATION_MYSQL2_CONFIG_OPTS` through

```bash
export OTEL_RUBY_INSTRUMENTATION_MYSQL2_CONFIG_OPTS='db_statement=include;'
```

or in your initialization step
or in your initialization step:

```ruby
ENV['OTEL_RUBY_INSTRUMENTATION_SINATRA_ENABLED'] = 'false'
ENV['OTEL_RUBY_INSTRUMENTATION_MYSQL2_CONFIG_OPTS'] = 'db_statement=include;'
```

See more details in [instrumentation-base](https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/opentelemetry-instrumentation-base/v0.22.3/instrumentation/base/lib/opentelemetry/instrumentation/base.rb#L56-L61)

## Configuration File

On startup, the library looks for the configuration file in the following locations under the application's current working directory:
Expand Down