Skip to content

Commit 69c9fd9

Browse files
committed
add troubleshooting in readme
1 parent e711c0b commit 69c9fd9

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

opentelemetry-auto-instrumentation/README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ gem install opentelemetry-auto-instrumentation
2323
```
2424

2525
Installing opentelemetry-auto-instrumentation will automatically install following gems:
26+
2627
```console
2728
opentelemetry-sdk
2829
opentelemetry-api
@@ -91,6 +92,14 @@ Since the `opentelemetry-auto-instrumentation` gem should be installed through `
9192
RUBYOPT="-r {PUT YOUR GEM PATH}/gems/opentelemetry-auto-instrumentation-0.1.0/lib/opentelemetry-auto-instrumentation" bundle exec rails server
9293
```
9394

95+
If you wish to load some gems outside the Gemfile, then they need to be placed in front of opentelemetry-auto-instrumentation:
96+
97+
```console
98+
export BUNDLE_WITHOUT=development,test
99+
gem install mysql2
100+
RUBYOPT="-r mysql2 -r opentelemetry-auto-instrumentation" ruby application.rb
101+
```
102+
94103
Instrument Sinatra application with rackup:
95104

96105
If you are using a Gemfile to install the required gems but without `Bundler.require`, set `REQUIRE_BUNDLER` to true. This way, `opentelemetry-auto-instrumentation` will call `Bundler.require` to initialize the required gems prior to SDK initialization.
@@ -100,13 +109,9 @@ export REQUIRE_BUNDLER=true
100109
RUBYOPT="-r opentelemetry-auto-instrumentation" rackup config.ru
101110
```
102111

103-
If you wish to load some gems outside the Gemfile, then they need to be placed in front of opentelemetry-auto-instrumentation:
112+
### Troubleshooting
104113

105-
```console
106-
export BUNDLE_WITHOUT=development,test
107-
gem install mysql2
108-
RUBYOPT="-r mysql2 -r opentelemetry-auto-instrumentation" ruby application.rb
109-
```
114+
The auto-instrumentation works by patching the `Bundler::Runtime#require` method to inject the `opentelemetry-auto-instrumentation` gem into your application. Rails applications automatically call `Bundler.require` during their boot process, so they work out of the box. However, many other frameworks (like Sinatra) do not call `Bundler.require` automatically, which means the OpenTelemetry SDK is never loaded. To fix this, explicitly call `Bundler.require` early in your application's startup process, or set the `OTEL_RUBY_REQUIRE_BUNDLER` environment variable to `true`.
110115

111116
## Example
112117

opentelemetry-auto-instrumentation/example/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
Install opentelemetry-auto-instrumentation through `gem install`
66
Then `bundle install`
77

8-
98
## Simple Example (simple-example)
109

1110
```bash
@@ -15,24 +14,28 @@ OTEL_RUBY_REQUIRE_BUNDLER=true OTEL_TRACES_EXPORTER=console RUBYOPT="-r opentel
1514
## Rails Example (rails-example)
1615

1716
Without auto-instrumentation
17+
1818
```bash
1919
bundle exec rackup config.ru
2020
```
2121

2222
In other terminal make the request call
23+
2324
```bash
2425
wget http://localhost:9292
2526
# or curl http://localhost:9292 if you have curl on system
2627
```
2728

2829
With auto-instrumentation
30+
2931
```bash
3032
OTEL_RUBY_REQUIRE_BUNDLER=false OTEL_TRACES_EXPORTER=console RUBYOPT="-r opentelemetry-auto-instrumentation" OTEL_RUBY_OPERATOR=false bundle exec rackup config.ru
3133
```
3234

3335
The load sequence must be opentelemetry-auto-instrumentation -> user library -> bundler.require (initialize otel sdk and instrumentation installation)
3436

3537
In other terminal make the request call
38+
3639
```bash
3740
wget http://localhost:9292
3841
# or curl http://localhost:9292 if you have curl on system

0 commit comments

Comments
 (0)