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: init-tracing-opentelemetry/README.md
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -253,6 +253,56 @@ Configure the following set of environment variables to configure the metrics ex
253
253
-`OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE` to set the temporality preference for the exporter
254
254
-`OTEL_METRIC_EXPORT_INTERVAL` to set frequence of metrics export in **_milliseconds_**, defaults to 60s
255
255
256
+
## Logs
257
+
258
+
To configure OpenTelemetry log export, enable the `logs` feature. This initializes a `SdkLoggerProvider` and adds a log bridge layer so that `tracing` events are forwarded to the OpenTelemetry log pipeline and exported via OTLP.
259
+
260
+
```toml
261
+
[dependencies]
262
+
init-tracing-opentelemetry = { version = "*", features = ["otlp", "logs"] }
263
+
```
264
+
265
+
Standard `tracing` macros emit logs that are automatically bridged:
tracing::error!("This is ground control to Major Tom");
273
+
tracing::warn!("Houston, we have a problem");
274
+
tracing::info!("We have contact");
275
+
tracing::debug!("Roger, copy that");
276
+
277
+
Ok(())
278
+
}
279
+
```
280
+
281
+
Log export can be toggled at runtime via `.with_logs(bool)`:
282
+
283
+
```rust,no_run
284
+
TracingConfig::default()
285
+
.with_logs(false) // disable log export (default: enabled when feature is active)
286
+
.init_subscriber()?;
287
+
```
288
+
289
+
Configure the following environment variables to control the logs exporter (in addition to the shared variables above):
290
+
291
+
-`OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` overrides `OTEL_EXPORTER_OTLP_ENDPOINT` for the log pipeline; for HTTP the path `/v1/logs` is appended automatically
292
+
-`OTEL_EXPORTER_OTLP_LOGS_PROTOCOL` overrides `OTEL_EXPORTER_OTLP_PROTOCOL`, falls back to port-based auto-detection
> **Note:** A protocol must be set (via env var or inferable from the endpoint port). If neither is found, no log exporter is created and a warning is emitted on target `otel::setup`.
0 commit comments