From df1afe5ac6952622647234e263606e9547ec2291 Mon Sep 17 00:00:00 2001 From: Alejandro Estringana Ruiz Date: Tue, 17 Dec 2024 12:36:42 +0100 Subject: [PATCH] Let standard limiters to work when standalone not enabled --- appsec/tests/extension/client_init_record_span_tags.phpt | 5 +++-- appsec/tests/extension/rinit_record_span_tags.phpt | 5 +++-- ext/asm_event.c | 6 +++++- .../curl/distributed_tracing_curl_propagate_asm_event.phpt | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/appsec/tests/extension/client_init_record_span_tags.phpt b/appsec/tests/extension/client_init_record_span_tags.phpt index 60f08e21ce..0e345b23a7 100644 --- a/appsec/tests/extension/client_init_record_span_tags.phpt +++ b/appsec/tests/extension/client_init_record_span_tags.phpt @@ -86,7 +86,7 @@ Array ( [_dd.appsec.json] => {"triggers":[{"found":"attack"},{"another":"attack"},{"yet another":"attack"}]} [_dd.p.appsec] => 1 - [_dd.p.dm] => -5 + [_dd.p.dm] => -0 [_dd.p.tid] => %s [_dd.runtime_family] => php [appsec.event] => true @@ -107,7 +107,8 @@ Array [metric_1] => 2 [metric_2] => 10 [_dd.appsec.enabled] => 1 - [_sampling_priority_v1] => 2 + [_dd.agent_psr] => 1 + [_sampling_priority_v1] => 1 [php.compilation.total_time_ms] => %f [php.memory.peak_usage_bytes] => %f [php.memory.peak_real_usage_bytes] => %f diff --git a/appsec/tests/extension/rinit_record_span_tags.phpt b/appsec/tests/extension/rinit_record_span_tags.phpt index 44826d6f8c..97b2d2c8e6 100644 --- a/appsec/tests/extension/rinit_record_span_tags.phpt +++ b/appsec/tests/extension/rinit_record_span_tags.phpt @@ -81,7 +81,7 @@ Array ( [_dd.appsec.json] => {"triggers":[{"found":"attack"},{"another":"attack"},{"yet another":"attack"}]} [_dd.p.appsec] => 1 - [_dd.p.dm] => -5 + [_dd.p.dm] => -0 [_dd.p.tid] => %s [_dd.runtime_family] => php [appsec.event] => true @@ -100,7 +100,8 @@ Array [%s] => %d [rshutdown_metric] => 2.1 [_dd.appsec.enabled] => 1 - [_sampling_priority_v1] => 2 + [_dd.agent_psr] => 1 + [_sampling_priority_v1] => 1 [php.compilation.total_time_ms] => %f [php.memory.peak_usage_bytes] => %f [php.memory.peak_real_usage_bytes] => %f diff --git a/ext/asm_event.c b/ext/asm_event.c index d729a285b5..7818cb077c 100644 --- a/ext/asm_event.c +++ b/ext/asm_event.c @@ -1,4 +1,6 @@ #include "asm_event.h" + +#include "configuration.h" #include "ddtrace.h" #include "priority_sampling/priority_sampling.h" #include "tracer_tag_propagation/tracer_tag_propagation.h" @@ -24,7 +26,9 @@ DDTRACE_PUBLIC void ddtrace_emit_asm_event() { ZVAL_STR(&_1_zval, _1_zstr); ddtrace_add_propagated_tag(_dd_tag_p_appsec_zstr, &_1_zval); - ddtrace_set_priority_sampling_on_root(PRIORITY_SAMPLING_USER_KEEP, DD_MECHANISM_ASM); + if (get_DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED()) { + ddtrace_set_priority_sampling_on_root(PRIORITY_SAMPLING_USER_KEEP, DD_MECHANISM_ASM); + } } PHP_FUNCTION(DDTrace_Testing_emit_asm_event) { diff --git a/tests/ext/integrations/curl/distributed_tracing_curl_propagate_asm_event.phpt b/tests/ext/integrations/curl/distributed_tracing_curl_propagate_asm_event.phpt index b354b00185..8d90dbae6c 100644 --- a/tests/ext/integrations/curl/distributed_tracing_curl_propagate_asm_event.phpt +++ b/tests/ext/integrations/curl/distributed_tracing_curl_propagate_asm_event.phpt @@ -6,6 +6,7 @@ Distributed tracing header tags propagate asm events with curl_exec() --ENV-- DD_TRACE_TRACED_INTERNAL_FUNCTIONS=curl_exec HTTP_X_DATADOG_TRACE_ID=42 +DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED=1 --FILE--