Add comments and remove unneeded code.
MODIFY
dd-trace-ot/src/main/java/datadog/opentracing/DDTracer.java
dd-trace-ot/src/main/java/datadog/opentracing/DDTracer.java
@@ -564,14 +564,7 @@ public class DDTracer implements io.opentracing.Tracer, Closeable, datadog.trace
// Get header tags whether propagating or not.
if (parentContext instanceof TagContext) {
- final TagContext tagContext = (TagContext) parentContext;
-
- if (tags.isEmpty() && !tagContext.getTags().isEmpty()) {
- tags = new HashMap<>();
- }
- if (!tagContext.getTags().isEmpty()) {
- tags.putAll(tagContext.getTags());
- }
+ tags.putAll(((TagContext) parentContext).getTags());
}
tags.put(Config.RUNTIME_ID_TAG, runtimeId);

MODIFY
dd-trace-ot/src/main/java/datadog/opentracing/propagation/ExtractedContext.java
dd-trace-ot/src/main/java/datadog/opentracing/propagation/ExtractedContext.java
@@ -3,6 +3,9 @@ package datadog.opentracing.propagation;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
+/**
+ * Propagated data resulting from calling tracer.extract with header data from an incoming request.
+ */
public class ExtractedContext extends TagContext {
private final String traceId;
private final String spanId;

MODIFY
dd-trace-ot/src/main/java/datadog/opentracing/propagation/TagContext.java
dd-trace-ot/src/main/java/datadog/opentracing/propagation/TagContext.java
@@ -4,6 +4,10 @@ import io.opentracing.SpanContext;
import java.util.Collections;
import java.util.Map;
+/**
+ * When calling extract, we allow for grabbing other configured headers as tags. Those tags are
+ * returned here even if the rest of the request would have returned null.
+ */
public class TagContext implements SpanContext {
private final Map<String, String> tags;

Add comments and remove unneeded code.