Skip to content
Permalink
Browse files
Use leading zeros in trace-id format for text headers
  • Loading branch information
Piotr Bober committed Nov 13, 2019
1 parent c65b3c7 commit 7a7b527898e413d76ddff0ec7d5c3486e1f4a109
Showing 2 changed files with 4 additions and 2 deletions.
@@ -229,7 +229,7 @@ get_flags_from_state(State) ->
state_to_string(State) ->
#?STATE{trace_id = TraceId, span_id = SpanId} = State,
Flags = get_flags_from_state(State),
list_to_binary(io_lib:format("~.16b:~.16b:~.16b:~.16b",
list_to_binary(io_lib:format("~32.16.0b:~16.16.0b:~.16b:~.16b",
[TraceId, SpanId, 0, Flags])).

-spec state_from_string(binary()) -> #?STATE{}.
@@ -56,9 +56,11 @@ propagation_test_() ->
Span0 = passage:start_span(foo, [{tracer, tracer}]),
Span1 = passage:set_baggage_items(Span0, #{<<"a">> => <<"b">>}),

#{<<"uber-trace-id">> := _, <<"uberctx-a">> := _} = Injected =
#{<<"uber-trace-id">> := TraceId, <<"uberctx-a">> := _} = Injected =
passage:inject_span(Span1, http_header, fun maps:put/3, #{}),

?assertEqual(match, re:run(TraceId, <<"^[0-9a-f]{32}:[0-9a-f]{16}:0:[0-3]$">>, [{capture, none}])),

Extracted =
passage:extract_span(
tracer, http_header,

0 comments on commit 7a7b527

Please sign in to comment.