Skip to content

Commit a35ba74

Browse files
jandro996devflow.devflow-routing-intake
andauthored
Fix and more tests (#10742)
Fix and more tests Merge branch 'master' into alejandro.gonzalez/APPSEC-61554-flaky-test Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>
1 parent bfde4ad commit a35ba74

File tree

1 file changed

+9
-4
lines changed
  • dd-java-agent/instrumentation/akka/akka-http/akka-http-10.0/src/main/java/datadog/trace/instrumentation/akkahttp

1 file changed

+9
-4
lines changed

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)