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

Commit 12e0522

Browse files
committed
smaller nits
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
1 parent 9dadd56 commit 12e0522

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

jaeger-core/src/main/java/io/jaegertracing/internal/propagation/TraceContextCodec.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package io.jaegertracing.internal.propagation;
1818

19-
import static io.jaegertracing.internal.propagation.B3TextMapCodec.SAMPLED_FLAG;
20-
2119
import io.jaegertracing.internal.JaegerObjectFactory;
2220
import io.jaegertracing.internal.JaegerSpanContext;
2321
import io.jaegertracing.spi.Codec;
@@ -52,7 +50,7 @@ public class TraceContextCodec implements Codec<TextMap> {
5250
SPAN_ID_OFFSET + SPAN_ID_HEX_SIZE + TRACEPARENT_DELIMITER_SIZE;
5351
private static final int TRACEPARENT_HEADER_SIZE = TRACE_OPTION_OFFSET + TRACE_OPTION_HEX_SIZE;
5452

55-
private static final byte JAEGER_SAMPLED_FLAG = 1;
53+
private static final byte SAMPLED_FLAG = 1;
5654

5755
private final JaegerObjectFactory objectFactory;
5856

@@ -79,10 +77,10 @@ private JaegerSpanContext extractContextFromTraceParent(String traceparent) {
7977
Long traceIdLow = HexCodec.hexToUnsignedLong(traceparent, TRACE_ID_OFFSET + 16, TRACE_ID_OFFSET + 32);
8078
Long spanId = HexCodec.hexToUnsignedLong(traceparent, SPAN_ID_OFFSET, SPAN_ID_OFFSET + 16);
8179

82-
byte flags = 0;
80+
boolean sampled = false;
8381
long traceContextFlags = HexCodec.hexToUnsignedLong(traceparent, TRACE_OPTION_OFFSET, TRACE_OPTION_OFFSET + 2);
8482
if ((traceContextFlags & SAMPLED_FLAG) == SAMPLED_FLAG) {
85-
flags |= JAEGER_SAMPLED_FLAG;
83+
sampled = true;
8684
}
8785

8886
if (traceIdLow == null || traceIdLow == 0 || spanId == null || spanId == 0) {
@@ -95,7 +93,7 @@ private JaegerSpanContext extractContextFromTraceParent(String traceparent) {
9593
traceIdLow,
9694
spanId,
9795
0,
98-
flags,
96+
sampled ? (byte)1 : (byte)0,
9997
Collections.<String, String>emptyMap(), null);
10098
}
10199

jaeger-core/src/test/java/io/jaegertracing/internal/propagation/TraceContextCodecTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@
2121
import static org.junit.Assert.assertTrue;
2222

2323
import io.jaegertracing.internal.JaegerSpanContext;
24-
import io.opentracing.propagation.TextMap;
2524
import io.opentracing.propagation.TextMapAdapter;
2625
import java.util.HashMap;
27-
import java.util.Iterator;
28-
import java.util.LinkedHashMap;
29-
import java.util.Map;
3026
import org.junit.Test;
3127

3228
/**
@@ -40,12 +36,10 @@ public class TraceContextCodecTest {
4036
public void support128BitTraceIdExtraction() {
4137
String hex128Bits = "463ac35c9f6413ad48485a3953bb6124";
4238
String parentSpan = "d1595c6ec91668af";
43-
4439
String tracecontext = String.format("00-%s-%s-01", hex128Bits, parentSpan);
4540

4641
TextMapAdapter textMap = new TextMapAdapter(new HashMap<>());
4742
textMap.put(TRACE_PARENT, tracecontext);
48-
4943
JaegerSpanContext context = traceContextCodec.extract(textMap);
5044

5145
assertNotNull(HexCodec.lowerHexToUnsignedLong(parentSpan));

0 commit comments

Comments
 (0)