feat(otel): export logs through the tracing pipeline, correlated with traces (#147)
Logs were a separate pipeline: env_logger in debug (never exported) and opentelemetry-appender-log in release (exported without trace context, so SigNoz could not link logs to traces). - tracing-subscriber `tracing-log` feature: try_init installs LogTracer, so log:: records become tracing events: one console format, and RUST_LOG per-module directives still apply to them. - opentelemetry-appender-tracing exports events as OTel log records when OTLP_OTLS_ENDPOINT is set (any build), stamped with the enclosing span's trace_id/span_id. A per-layer filter drops the exporter's own crates. - The OTel span layer keeps only WARN/ERROR events as span events; the info/debug copies duplicated the correlated logs. - Remove env_logger init in the server, init_logs, and the unused opentelemetry-appender-log / opentelemetry-stdout deps. - tests/otel_log_correlation.rs pins correlation (native + bridged), the span-event filter, and per-module filtering of bridged records. - Constitution 1.2.0 (Principle V logging rule), CLAUDE.md, README, .env.example. Closes #147 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
79b339a2a6
commit
3b3e6bdb39
9 files changed
+284
-106
No files matched your search
@@ -593,6 +593,14 @@ an incoming `traceparent`). Conventions:
|
||||
never hold `span.enter()` across an `.await`.
|
||||
- DB: `otel::trace_db_call`; LLM: `otel::start_llm_request_span` (injects
|
||||
`traceparent` downstream).
|
||||
- **Logs ride the same subscriber.** `log::` records are bridged into
|
||||
`tracing` (the `tracing-log` feature), so there's one console format, and
|
||||
with `OTLP_OTLS_ENDPOINT` set every event is exported as an OTel log record
|
||||
stamped with its span's trace_id / span_id (`opentelemetry-appender-tracing`)
|
||||
— SigNoz links logs to traces. Prefer `tracing::` macros in new code:
|
||||
bridged records export with target `log` (module only in `code.namespace`).
|
||||
The span layer keeps only WARN/ERROR events as span events (error events
|
||||
set span status); `tests/otel_log_correlation.rs` pins all of this.
|
||||
- **`RUST_LOG` gates spans, not just logs.** The subscriber's single
|
||||
`EnvFilter` sits in front of both the console and the OTel layer, so a span
|
||||
below the filter level is never created: it's missing from the export, it
|
||||
@@ -956,7 +964,7 @@ side if exposing beyond a trusted network.
|
||||
- **image**: Thumbnail generation
|
||||
- **walkdir**: Directory traversal
|
||||
- **rayon**: Parallel processing
|
||||
- **tracing** + **tracing-opentelemetry** + **tracing-actix-web**: spans (exported via `opentelemetry-otlp`)
|
||||
- **tracing** + **tracing-opentelemetry** + **tracing-actix-web**: spans (exported via `opentelemetry-otlp`); logs via **opentelemetry-appender-tracing**
|
||||
- **bcrypt**: Password hashing
|
||||
- **infer**: Magic number file type detection
|
||||
|
||||
|
||||
Reference in new issue
Block a user