move multi-value aware logic to Extractor.
MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/OpenTracing32.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/OpenTracing32.java
@@ -298,7 +298,11 @@ public final class OpenTracing32 implements TracerAPI {
private Extractor(final C carrier, final Getter<C> getter) {
extracted = new HashMap<>();
for (final String key : getter.keys(carrier)) {
- extracted.put(key, getter.get(carrier, key));
+ // extracted header value
+ String s = getter.get(carrier, key);
+ // in case of multiple values in the header, need to parse
+ if (s != null) s = s.split(",")[0].trim();
+ extracted.put(key, s);
}
}

MODIFY
dd-java-agent/instrumentation/servlet/request-2/src/main/java/datadog/trace/instrumentation/servlet2/HttpServletRequestExtractAdapter.java
dd-java-agent/instrumentation/servlet/request-2/src/main/java/datadog/trace/instrumentation/servlet2/HttpServletRequestExtractAdapter.java
@@ -29,8 +29,6 @@ public class HttpServletRequestExtractAdapter
if (attribute instanceof String) {
return (String) attribute;
}
- String s = carrier.getHeader(key);
- if (s == null) return null;
- return s.split(",")[0].trim();
+ return carrier.getHeader(key);
}
}

MODIFY
dd-java-agent/instrumentation/servlet/request-3/src/main/java/datadog/trace/instrumentation/servlet3/HttpServletRequestExtractAdapter.java
dd-java-agent/instrumentation/servlet/request-3/src/main/java/datadog/trace/instrumentation/servlet3/HttpServletRequestExtractAdapter.java
@@ -29,8 +29,6 @@ public class HttpServletRequestExtractAdapter
if (attribute instanceof String) {
return (String) attribute;
}
- String s = carrier.getHeader(key);
- if (s == null) return null;
- return s.split(",")[0].trim();
+ return carrier.getHeader(key);
}
}

move multi-value aware logic to Extractor.