Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
Tolerate reads of 128 bit X-B3-TraceId (#52)
Browse files Browse the repository at this point in the history
The first step of transitioning to 128bit `X-B3-TraceId` is tolerantly reading 32 character long ids by throwing away the high bits (any characters left of 16 characters). This allows the tracing system to more flexibly introduce 128bit trace id support in the future.

Ex. when `X-B3-TraceId: 463ac35c9f6413ad48485a3953bb6124` is received, parse the lower 64 bits (right most 16 characters ex48485a3953bb6124) as the trace id.

See openzipkin/b3-propagation#6
  • Loading branch information
adriancole authored and yurishkuro committed Sep 15, 2016
1 parent ce4e159 commit 9b067f1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 4 additions & 4 deletions jaeger-zipkin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ apply plugin: 'com.github.kt3k.coveralls'
description = 'Integration library for Zipkin'

dependencies {
compile group: 'io.zipkin.reporter', name: 'zipkin-reporter', version: '0.4.2'
compile group: 'io.zipkin.reporter', name: 'zipkin-sender-urlconnection', version: '0.4.2'
compile group: 'io.zipkin.reporter', name: 'zipkin-reporter', version: '0.4.4'
compile group: 'io.zipkin.reporter', name: 'zipkin-sender-urlconnection', version: '0.4.4'
compile project(':jaeger-core')

testCompile group: 'junit', name: 'junit', version: junitVersion
testCompile group: 'org.mockito', name: 'mockito-all', version: mockitoVersion
testCompile group: 'io.zipkin.java', name: 'zipkin-junit', version: '1.8.3'
testCompile group: 'io.zipkin.brave', name: 'brave-http', version: '3.10.0'
testCompile group: 'io.zipkin.java', name: 'zipkin-junit', version: '1.11.1'
testCompile group: 'io.zipkin.brave', name: 'brave-http', version: '3.11.0'
}

jacocoTestReport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import zipkin.internal.Util;

import static com.uber.jaeger.propagation.b3.B3TextMapCodec.SPAN_ID_NAME;
import static com.uber.jaeger.propagation.b3.B3TextMapCodec.TRACE_ID_NAME;
import static org.junit.Assert.assertEquals;

public class B3TextMapCodecTest {
Expand All @@ -53,6 +56,21 @@ public void testExtract_rootSpan() throws Exception {
assertEquals(1, context.getFlags()); // sampled
}

@Test
public void downgrades128BitTraceIdToLower64Bits() throws Exception {
String hex128Bits = "463ac35c9f6413ad48485a3953bb6124";
String lower64Bits = "48485a3953bb6124";

DelegatingTextMap textMap = new DelegatingTextMap();
textMap.put(TRACE_ID_NAME, hex128Bits);
textMap.put(SPAN_ID_NAME, lower64Bits);

SpanContext context = b3Codec.extract(textMap);

assertEquals(Util.lowerHexToUnsignedLong(lower64Bits), context.getTraceID());
assertEquals(Util.lowerHexToUnsignedLong(lower64Bits), context.getSpanID());
}

@Test
public void testExtract_childSpan() throws Exception {
SpanId spanId = SpanId.builder().spanId(2L).traceId(1L).parentId(1L).build();
Expand Down

0 comments on commit 9b067f1

Please sign in to comment.