-
Notifications
You must be signed in to change notification settings - Fork 38
format b3 headers as 16 chars when 64 bit #166
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
345c017
to
2c1a87a
Compare
2c1a87a
to
838b22a
Compare
src/oc_propagation_http_b3.erl
Outdated
@@ -39,7 +39,7 @@ to_headers(#span_ctx{trace_id=TraceId, | |||
trace_options=TraceOptions}) -> | |||
Options = case TraceOptions band 1 of 1 -> "1"; _ -> "0" end, | |||
%% iolist_to_binary only needed for versions before otp-21 | |||
EncodedTraceId = iolist_to_binary(io_lib:format("~32.16.0b", [TraceId])), | |||
EncodedTraceId = iolist_to_binary(io_lib:format("~.16b", [TraceId])), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can either do this or check if the integer is between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807 in a guard. Thought this might be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can also do binary:encode_unsigned(TraceId)
and check if its size 64 or 128 before formatting it. Let me know which approach you prefer.
Since b3 trace IDs can be either 64 or 128 bit, we should check the size of the traceID and encode it according to its size instead of always encoding it as 32 chars.