Tracing: per-request root span via tracing-actix-web middleware (#139)
Add a conventional per-request OTel server span using the standard tracing-actix-web middleware (TracingLogger) as the outermost middleware, so the whole request lives under one root span and an incoming W3C traceparent is extracted onto it via the global text-map propagator (installed in #138). extract_context_from_request now sources the operation span's parent from that root span (tracing::Span::current().context()) instead of re-parsing the header, so per-handler operation spans nest under the root span as one trace tree rather than duplicating it as a sibling. Header parsing remains as a fallback for handlers invoked without the middleware (tests). The literal per-handler span boilerplate is intentionally NOT removed here; it becomes #[instrument] in the LLM (#140) and DAO (#141) migrations, where the &Context threading disappears entirely. tests/otel_traceparent.rs pins the behavior end-to-end: an incoming traceparent's trace_id propagates to the request, the root span is parented on the caller's (remote) span, and the operation span nests under the root span rather than alongside it.
This commit is contained in:
1 parent
e93f6b6d69
commit
7a59afc62b
5 files changed
+148
No files matched your search
Generated
+22
@@ -2124,6 +2124,7 @@ dependencies = [
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
"tracing-actix-web",
|
||||
"tracing-opentelemetry",
|
||||
"tracing-subscriber",
|
||||
"tzf-rs",
|
||||
@@ -2543,6 +2544,12 @@ version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13d2233c9842d08cfe13f9eac96e207ca6a2ea10b80259ebe8ad0268be27d2af"
|
||||
|
||||
[[package]]
|
||||
name = "mutually_exclusive_features"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e94e1e6445d314f972ff7395df2de295fe51b71821694f0b0e1e79c4f12c8577"
|
||||
|
||||
[[package]]
|
||||
name = "native-tls"
|
||||
version = "0.2.18"
|
||||
@@ -4359,6 +4366,21 @@ dependencies = [
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-actix-web"
|
||||
version = "0.7.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3133a9a17a910bb708dcdcf1ff89d3dd98d412938b5e017c6e42de11b63ef164"
|
||||
dependencies = [
|
||||
"actix-web",
|
||||
"mutually_exclusive_features",
|
||||
"opentelemetry",
|
||||
"pin-project-lite",
|
||||
"tracing",
|
||||
"tracing-opentelemetry",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.31"
|
||||
|
||||
Reference in new issue
Block a user