You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/shipping/Code/ruby.md
+42-59Lines changed: 42 additions & 59 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,124 +27,107 @@ Ruby OpenTelemetry logging support is experimental. This guide provides the most
27
27
28
28
* Ruby 3.1 or later
29
29
* Bundler for dependency management
30
-
* A Logz.io account with a shipping token
30
+
* A Logz.io account with a log shipping token
31
31
32
32
33
33
### Install dependencies (gems)
34
34
35
+
_If your Gemfile already contains `opentelemetry-exporter-otlp` (for tracing or metrics), leave that gem in your Gemfile and run `bundle update opentelemetry-exporter-otlp` to upgrade it._
36
+
37
+
Run a single `bundle add` command from your project root:
38
+
35
39
```bash
36
40
bundle add opentelemetry-sdk \
37
-
opentelemetry-exporter-otlp \
38
41
opentelemetry-logs-api \
39
42
opentelemetry-logs-sdk \
40
43
opentelemetry-exporter-otlp-logs
41
44
```
42
-
43
45
The `opentelemetry-exporter-otlp-logs` gem provides experimental OTLP-over-HTTP exporter for logs.
Replace `<LOG-SHIPPING-TOKEN>` with your Logz.io shipping token and `<YOUR-SERVICE-NAME>` with your service name.
56
63
57
-
### Initialize OpenTelemetry in Rails
64
+
If the application already exports traces or metrics with a different OTLP endpoint, ensure that endpoint ends with `/v1/logs` so logs are routed correctly.
65
+
66
+
### Instrument the application
58
67
59
-
Add this configuration to your Ruby application (at the top of your main file):
68
+
Add the block below at the top of your main script. For **Rails**, create `config/initializers/opentelemetry_logs.rb` with the code.
Open Explore in the Logz.io UI, filter by the service name you set, and confirm that the new log entries appear after a short ingestion delay.
131
120
132
-
logger.on_emit(
133
-
body:'Processing complete',
134
-
severity_text:'INFO',
135
-
attributes: { 'records_processed' => '1000' }
136
-
)
137
-
```
121
+
### Troubleshooting
138
122
139
-
### Run the application
123
+
* A `Bundler::GemRequireError` about duplicate gems means `opentelemetry-exporter-otlp` appears twice inthe Gemfile with different version constraints. Keep one line and run `bundle install` again.
140
124
141
-
`bundle exec ruby your_app.rb`
125
+
* A `LoadError`for`opentelemetry/logs/sdk` indicates the require path is incorrect. Use `require 'opentelemetry-logs-sdk'`.
142
126
143
-
Generate some traffic; the logs will stream to Logz.io in OTLP format.
127
+
* An `OpenTelemetry::SDK::ConfigurationError` mentioning an invalid URL usually means `OTEL_EXPORTER_OTLP_ENDPOINT` is unset or malformed. Confirm the full HTTPS URL ends with `/v1/logs`.
144
128
145
-
### Verify in Logz.io
129
+
Once the endpoint and headers are valid, logs flow automatically through the exporter and become searchable inyour Logz.io account.
146
130
147
-
Open Explore, select the service name you set, and confirm the new log entries are present. Allow a few minutea for ingestion.
0 commit comments