Skip to content

Commit 86745ad

Browse files
committed
Fix and more tests
1 parent 70410da commit 86745ad

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

  • dd-java-agent/instrumentation/akka/akka-http/akka-http-10.0/src/main/java/datadog/trace/instrumentation/akkahttp

dd-java-agent/instrumentation/akka/akka-http/akka-http-10.0/src/main/java/datadog/trace/instrumentation/akkahttp/AkkaHttpServerHeaders.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,19 @@ private static void doForEachKey(
3131
HttpMessage carrier,
3232
akka.http.javadsl.model.HttpEntity entity,
3333
AgentPropagation.KeyClassifier classifier) {
34-
if (entity instanceof HttpEntity.Strict) {
35-
HttpEntity.Strict strictEntity = (HttpEntity.Strict) entity;
36-
ContentType contentType = strictEntity.contentType();
34+
// In Akka HTTP, Content-Type is part of the entity, not a regular header.
35+
// Extract it for all entity types (Default, Chunked, etc.), not only Strict.
36+
if (entity instanceof HttpEntity) {
37+
ContentType contentType = ((HttpEntity) entity).contentType();
3738
if (contentType != null) {
38-
if (!classifier.accept("content-type", contentType.value())) {
39+
String contentTypeValue = contentType.value();
40+
if (!contentTypeValue.isEmpty() && !classifier.accept("content-type", contentTypeValue)) {
3941
return;
4042
}
4143
}
44+
}
45+
if (entity instanceof HttpEntity.Strict) {
46+
HttpEntity.Strict strictEntity = (HttpEntity.Strict) entity;
4247
if (!classifier.accept("content-length", Long.toString(strictEntity.contentLength()))) {
4348
return;
4449
}

0 commit comments

Comments
 (0)