Skip to content
Permalink
Browse files
Merge pull request #1 from relayr/trace-id-leading-zeros
Use leading zeros in trace-id format for text headers
  • Loading branch information
sile committed Nov 14, 2019
2 parents c65b3c7 + 7a7b527 commit 3d6e367df6e4223ffeb86a7bdbdb8d19a0ba64d2
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 3d6e367

Please sign in to comment.