Skip to content

Commit cc9ee12

Browse files
committed
Add spanid and traceid metadata to greylog
1 parent 52cb04d commit cc9ee12

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/workflows/recipe/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,20 @@ def unwrap_recipe(header, message):
102102
if dcid:
103103
span.set_attribute("dcid", dcid)
104104
span.add_event("recipe.dcid_extracted", attributes={"dcid": dcid})
105+
106+
# Extract span_id and trace_id for logging
107+
span_context = span.get_span_context()
108+
if span_context.is_valid:
109+
span_id = format(span_context.span_id, '016x')
110+
trace_id = format(span_context.trace_id, '032x')
111+
112+
logger.info(
113+
"Processing recipe message",
114+
extra={
115+
"span_id": span_id,
116+
"trace_id": trace_id,
117+
}
118+
)
105119

106120
if log_extender and rw.environment and rw.environment.get("ID"):
107121
with log_extender("recipe_ID", rw.environment["ID"]):

0 commit comments

Comments
 (0)