Skip to content

Commit 1ec9641

Browse files
committed
waf/rasp.duration/_ext all in microsseconds -- span or telemetry
1 parent 562652c commit 1ec9641

29 files changed

Lines changed: 64 additions & 33 deletions

.claude/ci/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ Note that path — it is the output file for the next step.
244244
.claude/ci/ci-watch [--start-offset N] OUTPUT_FILE
245245
```
246246

247+
**`OUTPUT_FILE` must be the output file from a `check-ci` process** — not an
248+
arbitrary background task. `ci-watch` parses `check-ci`'s structured
249+
`FAILED:` / `SUCCESS:` lines and exits silently on anything else.
250+
247251
`ci-watch` tails the output file and exits when there is something to
248252
act on. Run it with `run_in_background: true` — you will be notified
249253
when it completes. While it runs, you can do other work.

appsec/helper-rust/src/client/metrics.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,15 @@ impl telemetry::TelemetryMetricsGenerator for WafMetrics {
265265
impl telemetry::SpanMetricsGenerator for WafMetrics {
266266
fn generate_span_metrics(&'_ self, submitter: &mut dyn telemetry::SpanMetricsSubmitter) {
267267
if !self.waf_duration.is_zero() {
268-
submitter.submit_metric(telemetry::WAF_DURATION, self.waf_duration.duration_ms_f64());
268+
submitter.submit_metric(
269+
telemetry::WAF_DURATION,
270+
self.waf_duration.as_micros() as f64,
271+
);
269272
}
270273
if !self.rasp_duration.is_zero() {
271274
submitter.submit_metric(
272275
telemetry::RAST_DURATION,
273-
self.rasp_duration.duration_ms_f64(),
276+
self.rasp_duration.as_micros() as f64,
274277
);
275278
}
276279
if self.rasp_rule_evals > 0 {

appsec/src/extension/commands/request_shutdown.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ static const char *nullable _header_content_type_zend_array(
2828
static const dd_command_spec _spec = {
2929
.name = "request_shutdown",
3030
.name_len = sizeof("request_shutdown") - 1,
31-
.num_args = 4, // a map, api sec sampling key, sidecar queue id, input_truncated
31+
.num_args =
32+
4, // a map, api sec sampling key, sidecar queue id, input_truncated
3233
.outgoing_cb = _request_pack,
3334
.incoming_cb = dd_command_proc_resp_verd_span_data,
3435
.config_features_cb = dd_command_process_config_features_unexpected,

appsec/src/extension/commands_helpers.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,16 +704,17 @@ void dd_command_process_meta(mpack_node_t root, zend_object *nonnull span)
704704
const char *val_str = mpack_node_str(value);
705705
size_t val_len = mpack_node_strlen(value);
706706

707-
bool res = dd_trace_span_add_tag_str(span, key_str, key_len,
708-
val_str, val_len);
707+
bool res =
708+
dd_trace_span_add_tag_str(span, key_str, key_len, val_str, val_len);
709709

710710
if (!res) {
711711
mlog(dd_log_warning, "Failed to add tag %.*s", (int)key_len,
712712
key_str);
713713
return;
714714
}
715715

716-
dd_telemetry_note_helper_string_meta(key_str, key_len, val_str, val_len);
716+
dd_telemetry_note_helper_string_meta(
717+
key_str, key_len, val_str, val_len);
717718
}
718719

719720
if (has_schemas && !get_DD_APM_TRACING_ENABLED()) {

appsec/src/extension/duration_acc.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#pragma once
22

3+
// php_compat.h must precede attributes.h: attributes.h defines `nonnull` as _Nonnull
4+
// (empty on GCC), which breaks PHP 8.4+'s __has_attribute(nonnull) in zend_portability.h.
5+
#include "php_compat.h" // NOLINT(llvm-include-order)
36
#include "attributes.h"
4-
#include "php_compat.h"
57
#include <time.h>
68

79
static inline struct timespec dd_monotime_start(void)
@@ -17,7 +19,7 @@ void dd_duration_reset_globals(void); // call on rinit/user req begin
1719
void dd_duration_flush_metrics(zend_object *nonnull span); // call on rshutdown/user req shutdown
1820

1921
// RASP round-trip time
20-
void dd_duration_rasp_ext_account(const struct timespec *start);
22+
void dd_duration_rasp_ext_account(const struct timespec *nonnull start);
2123

2224
// Non-RASP WAF round-trip time
23-
void dd_duration_waf_ext_account(const struct timespec *start);
25+
void dd_duration_waf_ext_account(const struct timespec *nonnull start);

appsec/tests/extension/client_init_record_span_tags.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Array
110110
(
111111
[%s] => %d
112112
[_dd.appsec.enabled] => 1
113+
[_dd.appsec.waf.duration_ext] => %f
113114
[_sampling_priority_v1] => 1
114115
[metric_1] => 2
115116
[metric_2] => 10

appsec/tests/extension/push_params_ok_04.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Array
3131
(
3232
[process_id] => %d
3333
[_dd.appsec.enabled] => %d
34+
[_dd.appsec.waf.duration_ext] => %f
3435
[_dd.appsec.rasp.duration_ext] => %f
3536
)
3637
array(2) {

appsec/tests/extension/push_params_ok_05.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Array
3232
(
3333
[process_id] => %d
3434
[_dd.appsec.enabled] => %d
35+
[_dd.appsec.waf.duration_ext] => %f
3536
)
3637
array(0) {
3738
}

appsec/tests/extension/push_params_ok_06.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Array
3131
(
3232
[process_id] => %d
3333
[_dd.appsec.enabled] => %d
34+
[_dd.appsec.waf.duration_ext] => %f
3435
)
3536
array(0) {
3637
}

appsec/tests/extension/rexec_force_keep_01.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ Array
3434
(
3535
[%s] => %d
3636
[_dd.appsec.enabled] => 1
37+
[_dd.appsec.waf.duration_ext] => %f
3738
)
3839
int(2)

0 commit comments

Comments
 (0)