Exporters that emit trace/span IDs as hex strings currently have only one option: trace_id.to_string() / span_id.to_string(), both of which heap-allocate a String on every call. On hot export paths this is two small allocations per record/span just to format already-known fixed-size data.
This affects OS-native exporters that pass IDs as a single counted UTF-8 field to the underlying logging substrate. OTLP and stdout do not hit this — OTLP serializes raw bytes, and stdout writes Display directly to the formatter.
It would be useful for opentelemetry::trace::TraceId / SpanId to expose an allocation-free way to obtain the lowercase hex representation.
Exporters that emit trace/span IDs as hex strings currently have only one option:
trace_id.to_string()/span_id.to_string(), both of which heap-allocate aStringon every call. On hot export paths this is two small allocations per record/span just to format already-known fixed-size data.This affects OS-native exporters that pass IDs as a single counted UTF-8 field to the underlying logging substrate. OTLP and stdout do not hit this — OTLP serializes raw bytes, and stdout writes
Displaydirectly to the formatter.It would be useful for
opentelemetry::trace::TraceId/SpanIdto expose an allocation-free way to obtain the lowercase hex representation.