-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add autoinstrumentation doc (#1060)
* Add autoinstrumentation docs + reorder some pages * revert page weighting and make the page about configuration * whoopsie * Apply suggestions from code review Co-authored-by: Ariel Valentin <arielvalentin@users.noreply.github.com> * Changes as per review feedback * link fixes Co-authored-by: Ariel Valentin <arielvalentin@users.noreply.github.com> Co-authored-by: Francis Bogsanyi <francis.bogsanyi@shopify.com>
- Loading branch information
1 parent
01b6790
commit 169f0b7
Showing
2 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
--- | ||
title: Configuring automatic instrumentation | ||
weight: 5 | ||
--- | ||
|
||
Automatic instrumentation in ruby is done via instrumentation packages, and most commonly, the `opentelemetry-instrumentation-all` package. These are called Instrumentation Libraries. | ||
|
||
For example, if you are using Rails and enable instrumentation, your running Rails app will automatically generate telemetry data for inbound requests to your controllers. | ||
|
||
### Configuring all instrumentation libraries | ||
|
||
The recommended way to use instrumentation libraries is to use the `opentelemetry-instrumentation-all` package: | ||
|
||
```console | ||
gem 'opentelemetry-sdk' | ||
gem 'opentelemetry-exporter-otlp' | ||
gem 'opentelemetry-instrumentation-all' | ||
``` | ||
|
||
and configure it early in your application lifecycle. See the example below using a Rails initializer: | ||
|
||
```ruby | ||
# config/initializers/opentelemetry.rb | ||
require 'opentelemetry/sdk' | ||
require 'opentelemetry/exporter/otlp' | ||
require 'opentelemetry/instrumentation/all' | ||
OpenTelemetry::SDK.configure do |c| | ||
c.service_name = '<YOUR_SERVICE_NAME>' | ||
c.use_all() # enables all instrumentation! | ||
end | ||
``` | ||
|
||
This will install all instrumentation libraries and enable the ones that match up to libraries you're using in your app. | ||
|
||
### Overriding configuration for specific instrumentation libraries | ||
|
||
If you are enabling all instrumentation but want to override the configuration for a specific one, call `use_all` with a configuration map parameter, where the key represents the library, and the value is its specific configuration parameter. | ||
|
||
For example, here's how you can install all instrumentations _except_ the `Redis` instrumentation into your app: | ||
|
||
```ruby | ||
require 'opentelemetry/sdk' | ||
require 'opentelemetry/instrumentation/all' | ||
|
||
OpenTelemetry::SDK.configure do |c| | ||
config = {'OpenTelemetry::Instrumentation::Redis' => { enabled: false }} | ||
c.use_all(config) | ||
end | ||
``` | ||
|
||
To override more instrumentation, add another entry in the `config` map. | ||
|
||
### Configuring specific instrumentation libraries | ||
|
||
If you prefer more selectively installing and using only specific instrumentation libraries, you can do that too. For example, here's how to use only `Sinatra` and `Faraday`, with `Farady` being configured with an additional configuration parameter. | ||
|
||
First, install the specific instrumentation libraries you know you want to use: | ||
|
||
```console | ||
gem install opentelemetry-instrumentation-sinatra | ||
gem install opentelemetry-instrumentation-faraday | ||
``` | ||
|
||
The configure them: | ||
|
||
|
||
```ruby | ||
require 'opentelemetry/sdk' | ||
|
||
# install all compatible instrumentation with default configuration | ||
OpenTelemetry::SDK.configure do |c| | ||
c.use 'OpenTelemetry::Instrumentation::Sinatra' | ||
c.use 'OpenTelemetry::Instrumentation::Faraday', { opt: 'value' } | ||
end | ||
``` | ||
|
||
### Next steps | ||
|
||
Instrumentation libraries are the easiest way to generate lots of useful telemetry data about your ruby apps. But they don't generate data specific to your application's logic! To do that, you'll need to enrich the automatic instrumentation from instrumentation libraries with [manual instrumentation](manual_instrumentation). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters