Skip to content

Commit

Permalink
Fix Open Telemetry framework example (#653)
Browse files Browse the repository at this point in the history
The `hex` function does not format the trace and span id correctly.  In as much as the spec [says](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#retrieving-the-traceid-and-spanid) the span-id and trace-id are fixed with hex numbers. 16 chars for the span-id and 32 for the trace-id.
  • Loading branch information
kain88-de authored Sep 25, 2024
1 parent 60f0931 commit 0bd3ac2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/frameworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ def add_open_telemetry_spans(_, __, event_dict):
parent = getattr(span, "parent", None)

event_dict["span"] = {
"span_id": hex(ctx.span_id),
"trace_id": hex(ctx.trace_id),
"parent_span_id": None if not parent else hex(parent.span_id),
"span_id": format(ctx.span_id, "016x"),
"trace_id": format(ctx.trace_id, "032x"),
"parent_span_id": None if not parent else format(parent.span_id, "016x"),
}

return event_dict
Expand Down

0 comments on commit 0bd3ac2

Please # to comment.