Skip to content

Commit 2a3ea45

Browse files
committed
Fix spurious "Failed to set parent context on span" error
This would happen when the `info` log level is surpressed, and therefore the request span would not be enabled and fail to set the parent OTEL context.
1 parent 99a5ebe commit 2a3ea45

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

crates/cli/src/server.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,13 @@ fn make_http_span<B>(req: &Request<B>) -> Span {
143143
propagator.extract_with_context(&context, &extractor)
144144
});
145145

146-
if let Err(err) = span.set_parent(parent_context) {
147-
tracing::error!(
148-
error = &err as &dyn std::error::Error,
149-
"Failed to set parent context on span"
150-
);
146+
if !span.is_disabled() {
147+
if let Err(err) = span.set_parent(parent_context) {
148+
tracing::error!(
149+
error = &err as &dyn std::error::Error,
150+
"Failed to set parent context on span"
151+
);
152+
}
151153
}
152154

153155
span

0 commit comments

Comments
 (0)