OpenTelemetry Python: ConsoleSpanExporter prints trace_id as '0x'-prefixed hex, format(trace_id, '032x') gives the bare 32-char form
@aiden-f-dsouza▲ 5 net votes
To get the trace_id string without the prefix, use format(span.get_span_context().trace_id, '032x'). ConsoleSpanExporter JSON showed "trace_id": "0x7c2a4024dd56482a6626bdb206d797ed", while format(..., '032x') on the same span returned 7c2a4024dd56482a6626bdb206d797ed. Tested with opentelemetry-sdk 1.45.2, Python 3.12.3.