Skip to content

Commit e327012

Browse files
Fix AppSec play.mvc.StatusHeader instrumentation for play 2.6 (#9160)
1 parent c949475 commit e327012

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

dd-java-agent/instrumentation/play-2.6/src/main/java/datadog/trace/instrumentation/play26/appsec/StatusHeaderInstrumentation.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ static void before(
9797
throw new BlockingException("Blocked request (for StatusHeader/sendJson)");
9898
}
9999
}
100-
}
101100

102-
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class)
103-
static void after() {
104-
CallDepthThreadLocalMap.decrementCallDepth(StatusHeader.class);
101+
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class)
102+
static void after() {
103+
CallDepthThreadLocalMap.decrementCallDepth(StatusHeader.class);
104+
}
105105
}
106106
}

dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/base/HttpServerTest.groovy

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,6 +2384,7 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
23842384
boolean bodyConvertedBlock
23852385
boolean responseHeadersInTags
23862386
boolean responseBodyTag
2387+
Object responseBody
23872388
}
23882389

23892390
static final String stringOrEmpty(String string) {
@@ -2399,6 +2400,9 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
23992400
final BiFunction<RequestContext, IGSpanInfo, Flow<Void>> requestEndedCb =
24002401
({ RequestContext rqCtxt, IGSpanInfo info ->
24012402
Context context = rqCtxt.getData(RequestContextSlot.APPSEC)
2403+
if (context.responseBodyTag) {
2404+
rqCtxt.traceSegment.setTagTop('response.body', context.responseBody)
2405+
}
24022406
if (context.extraSpanName) {
24032407
runUnderTrace(context.extraSpanName, false) {
24042408
def span = activeSpan()
@@ -2547,9 +2551,7 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
25472551
body = obj.toString()
25482552
}
25492553
Context context = rqCtxt.getData(RequestContextSlot.APPSEC)
2550-
if (context.responseBodyTag) {
2551-
rqCtxt.traceSegment.setTagTop('response.body', body)
2552-
}
2554+
context.responseBody = body
25532555
if (context.responseBlock) {
25542556
new RbaFlow(
25552557
new Flow.Action.RequestBlockingAction(413, BlockingContentType.JSON)

0 commit comments

Comments
 (0)