@@ -837,19 +837,15 @@ private NoopFlow onRequestEnded(RequestContext ctx_, IGSpanInfo spanInfo) {
837837 Map <String , Object > tags = spanInfo .getTags ();
838838
839839 boolean sampledForApiSec = maybeSampleForApiSecurity (ctx , spanInfo , tags );
840- boolean apmTracingEnabled = Config .get ().isApmTracingEnabled ();
841840
842841 if (!sampledForApiSec ) {
843842 ctx .closeWafContext ();
844843 }
845844
846845 // AppSec report metric and events for web span only
847846 if (traceSeg != null ) {
848- // Set API Security sampling tags if needed
849- if (sampledForApiSec && !apmTracingEnabled ) {
847+ if (sampledForApiSec && !Config .get ().isApmTracingEnabled ()) {
850848 traceSeg .setTagTop (Tags .ASM_KEEP , true );
851- // Must set _dd.p.ts locally so TraceCollector respects force-keep in standalone mode
852- // (TraceCollector.java lines 67-74 ignore force-keep without _dd.p.ts when APM disabled)
853849 traceSeg .setTagTop (Tags .PROPAGATED_TRACE_SOURCE , ProductTraceSource .ASM );
854850 }
855851
@@ -869,8 +865,7 @@ private NoopFlow onRequestEnded(RequestContext ctx_, IGSpanInfo spanInfo) {
869865
870866 // If detected any events - mark span at appsec.event
871867 if (!collectedEvents .isEmpty ()) {
872- boolean manuallyKept = ctx .isManuallyKept ();
873- if (manuallyKept ) {
868+ if (ctx .isManuallyKept ()) {
874869 // Set asm keep in case that root span was not available when events are detected
875870 traceSeg .setTagTop (Tags .ASM_KEEP , true );
876871 traceSeg .setTagTop (Tags .PROPAGATED_TRACE_SOURCE , ProductTraceSource .ASM );
@@ -942,14 +937,11 @@ private NoopFlow onRequestEnded(RequestContext ctx_, IGSpanInfo spanInfo) {
942937 private boolean maybeSampleForApiSecurity (
943938 AppSecRequestContext ctx , IGSpanInfo spanInfo , Map <String , Object > tags ) {
944939 log .debug ("Checking API Security for end of request handler on span: {}" , spanInfo .getSpanId ());
945-
946940 // API Security sampling requires http.route tag.
947941 final Object route = tags .get (Tags .HTTP_ROUTE );
948-
949942 if (route != null ) {
950943 ctx .setRoute (route .toString ());
951944 }
952-
953945 ApiSecuritySampler requestSampler = requestSamplerSupplier .get ();
954946 return requestSampler .preSampleRequest (ctx );
955947 }
0 commit comments