Skip to content

Commit 4202c21

Browse files
committed
Give span_id and trace_id their own log_extender contexts, so that they can be searched by greylog
1 parent 4004a7d commit 4202c21

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/workflows/recipe/__init__.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,13 @@ def unwrap_recipe(header, message):
8181

8282
# Extract span_id and trace_id for logging
8383
span_context = span.get_span_context()
84-
otel_logs = None
85-
if span_context.is_valid:
86-
span_id = span_context.span_id
87-
trace_id = span_context.trace_id
88-
89-
otel_logs = {
90-
"span_id": span_id,
91-
"trace_id": trace_id,
92-
"recipe_id": recipe_id,
93-
}
9484

9585
with ExitStack() as stack:
96-
# Configure the context depending on if service is emitting spans
86+
# Configure the context depending on if service is emitting valid spans
9787
stack.enter_context(log_extender("recipe_ID", recipe_id))
98-
if otel_logs:
99-
stack.enter_context(log_extender("otel_logs", otel_logs))
88+
if span_context.is_valid:
89+
stack.enter_context(log_extender("span_id", span_context.span_id))
90+
stack.enter_context(log_extender("trace_id", span_context.trace_id))
10091
return callback(rw, header, message.get("payload"))
10192

10293
return callback(rw, header, message.get("payload"))

0 commit comments

Comments
 (0)