diff --git a/propagation/pom.xml b/propagation/pom.xml
index 13cf3bb23a..e12bdd0bd6 100644
--- a/propagation/pom.xml
+++ b/propagation/pom.xml
@@ -20,7 +20,7 @@
io.zipkin.brave
brave-parent
- 5.10.3-SNAPSHOT
+ 5.11.3-SNAPSHOT
brave-propagation-parent
diff --git a/propagation/w3c/pom.xml b/propagation/w3c/pom.xml
index 700d504c19..3f8b5947cb 100644
--- a/propagation/w3c/pom.xml
+++ b/propagation/w3c/pom.xml
@@ -18,7 +18,7 @@
io.zipkin.brave
brave-propagation-parent
- 5.10.3-SNAPSHOT
+ 5.11.3-SNAPSHOT
4.0.0
diff --git a/propagation/w3c/src/main/java/brave/propagation/w3c/TraceContextExtractor.java b/propagation/w3c/src/main/java/brave/propagation/w3c/TraceContextExtractor.java
index ba914671dc..6b2910d4d2 100644
--- a/propagation/w3c/src/main/java/brave/propagation/w3c/TraceContextExtractor.java
+++ b/propagation/w3c/src/main/java/brave/propagation/w3c/TraceContextExtractor.java
@@ -14,38 +14,37 @@
package brave.propagation.w3c;
import brave.propagation.Propagation.Getter;
-import brave.propagation.SamplingFlags;
import brave.propagation.TraceContext;
import brave.propagation.TraceContext.Extractor;
import brave.propagation.TraceContextOrSamplingFlags;
-import brave.propagation.w3c.TraceContextPropagation.Extra;
-import java.util.Collections;
-import java.util.List;
import static brave.propagation.B3SingleFormat.parseB3SingleFormat;
// TODO: this class has no useful tests wrt traceparent yet
-final class TraceContextExtractor implements Extractor {
- final Getter getter;
+final class TraceContextExtractor implements Extractor {
+ static final TraceContextOrSamplingFlags EXTRACTED_EMPTY =
+ TraceContextOrSamplingFlags.EMPTY.toBuilder().addExtra(Tracestate.EMPTY).build();
+
+ final Getter getter;
final K traceparentKey, tracestateKey;
final TracestateFormat tracestateFormat;
final B3SingleFormatHandler handler = new B3SingleFormatHandler();
- TraceContextExtractor(TraceContextPropagation propagation, Getter getter) {
+ TraceContextExtractor(TraceContextPropagation propagation, Getter getter) {
this.getter = getter;
this.traceparentKey = propagation.traceparent;
this.tracestateKey = propagation.tracestate;
this.tracestateFormat = new TracestateFormat(propagation.tracestateKey);
}
- @Override public TraceContextOrSamplingFlags extract(C carrier) {
- if (carrier == null) throw new NullPointerException("carrier == null");
- String traceparent = getter.get(carrier, traceparentKey);
- if (traceparent == null) return EMPTY;
+ @Override public TraceContextOrSamplingFlags extract(R request) {
+ if (request == null) throw new NullPointerException("request == null");
+ String traceparentString = getter.get(request, traceparentKey);
+ if (traceparentString == null) return EXTRACTED_EMPTY;
// TODO: add link that says tracestate itself is optional
- String tracestate = getter.get(carrier, tracestateKey);
- if (tracestate == null) {
+ String tracestateString = getter.get(request, tracestateKey);
+ if (tracestateString == null) {
// NOTE: we may not want to pay attention to the sampled flag. Since it conflates
// not-yet-sampled with sampled=false, implementations that always set flags to -00 would
// never be traced!
@@ -54,33 +53,20 @@ final class TraceContextExtractor implements Extractor {
// span ID. Ex we don't know if upstream are sending to the same system or not, when we can't
// read the tracestate header. Trusting the span ID (traceparent calls the span ID parent-id)
// could result in a headless trace.
- TraceContext maybeUpstream = TraceparentFormat.parseTraceparentFormat(traceparent);
- return TraceContextOrSamplingFlags.newBuilder()
- .context(maybeUpstream)
- .extra(DEFAULT_EXTRA) // marker for outbound propagation
- .build();
+ TraceContext maybeUpstream = TraceparentFormat.parseTraceparentFormat(traceparentString);
+ return TraceContextOrSamplingFlags.newBuilder(maybeUpstream)
+ .addExtra(Tracestate.EMPTY) // marker for outbound propagation
+ .build();
}
- CharSequence otherEntries = tracestateFormat.parseAndReturnOtherEntries(tracestate, handler);
-
- List