-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes 64-bit traces to left-pad 0s
Doing so helps remove confusion with 64-bit trace ids, which are encoded by Zipkin with 16 characters (implicitly padded left with zeros).
- Loading branch information
Adrian Cole
committed
Dec 20, 2016
1 parent
7beea93
commit c4dd5cd
Showing
2 changed files
with
6 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,12 +92,8 @@ private void finishTrace(Trace.Builder traceBuilder, Collection<Trace> converted | |
static String convertTraceId(Span zipkinSpan) { | ||
// Stackdriver trace ID's are 128 bits = 16 bytes * 8 | ||
ByteBuffer idBuffer = ByteBuffer.allocate(16); // or 32 characters | ||
// Some users call the Stackdriver API and order results by traceId to get a "random sample" of | ||
// traces. Duplicating the 64-bit ID instead of padding the ID with zeros will remove some | ||
// sampling bias for any projects that contain both Zipkin and Stackdriver traces. Regardless of | ||
// if we pad-left 0s or duplicate traceId, this resulting ID won't match Zipkin anyway as it | ||
// conditionally encodes 16 characters if high bits are unset (as opposed to padding to 32). | ||
idBuffer.putLong(zipkinSpan.traceIdHigh == 0L ? zipkinSpan.traceId : zipkinSpan.traceIdHigh); | ||
// Note that when 64-bit trace IDs are used, the left-most 16 characters will be zero | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
codefromthecrypt
via email
Member
|
||
idBuffer.putLong(zipkinSpan.traceIdHigh); | ||
idBuffer.putLong(zipkinSpan.traceId); | ||
StringBuilder idBuilder = new StringBuilder(); | ||
for (byte b : idBuffer.array()) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@adriancole @kevinmdavis Will the change work in mixed environments: i.e. some legacy component on Zipkin64 and newish components on Zipkin128?