@@ -94,6 +94,44 @@ class Apache2FpmTests implements CommonTests, SamplingTestsInFpm {
9494 php-fpm -y /etc/php-fpm.conf -c /etc/php/php.ini''' )
9595 }
9696
97+ @Test
98+ void ' resource renaming auto-enabled with appsec' () {
99+ // By default, DD_APPSEC_ENABLED=true is set but DD_TRACE_RESOURCE_RENAMING_ENABLED is not set.
100+ def req = container. buildReq(' /hello.php' ). GET (). build()
101+ def trace = container. traceFromRequest(req, ofString()) { HttpResponse<String > resp ->
102+ assert resp. body() == ' Hello world!'
103+ }
104+
105+ def span = trace. first()
106+ assert span. metrics. " _dd.appsec.enabled" == 1.0d : " AppSec should be enabled"
107+ assert span. meta. " http.endpoint" == ' /hello.php' : " http.endpoint tag should be set when AppSec is enabled"
108+ }
109+
110+ @Test
111+ void ' resource renaming disabled when explicitly set to false' () {
112+ // When DD_TRACE_RESOURCE_RENAMING_ENABLED=false is explicitly set, resource renaming should be disabled
113+ // even when AppSec is enabled
114+ def res = container. execInContainer(
115+ ' bash' , ' -c' ,
116+ ''' kill -9 `pgrep php-fpm`;
117+ export DD_TRACE_RESOURCE_RENAMING_ENABLED=false;
118+ php-fpm -y /etc/php-fpm.conf -c /etc/php/php.ini''' )
119+ assert res. exitCode == 0
120+
121+ try {
122+ def req = container. buildReq(' /hello.php' ). GET (). build()
123+ def trace = container. traceFromRequest(req, ofString()) { HttpResponse<String > resp ->
124+ assert resp. body() == ' Hello world!'
125+ }
126+
127+ def span = trace. first()
128+ assert span. metrics. " _dd.appsec.enabled" == 1.0d : " AppSec should still be enabled"
129+ assert span. meta. " http.endpoint" == null : " http.endpoint tag should NOT be set when resource renaming is explicitly disabled"
130+ } finally {
131+ resetFpm()
132+ }
133+ }
134+
97135 @Test
98136 void ' test sampling priority' () {
99137 // Set rate limit to 5 to ensure fewer than 15 events get sampling priority 2
0 commit comments