Skip to content

Commit 50a1739

Browse files
committed
waf/rasp.duration/_ext all in microsseconds -- span or telemetry
1 parent e6c20bc commit 50a1739

4 files changed

Lines changed: 33 additions & 16 deletions

File tree

.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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,12 @@ 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(telemetry::WAF_DURATION, self.waf_duration.as_micros() as f64);
269269
}
270270
if !self.rasp_duration.is_zero() {
271271
submitter.submit_metric(
272272
telemetry::RAST_DURATION,
273-
self.rasp_duration.duration_ms_f64(),
273+
self.rasp_duration.as_micros() as f64,
274274
);
275275
}
276276
if self.rasp_rule_evals > 0 {

appsec/tests/integration/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,13 +710,19 @@ def runMainTask = { String phpVersion, String variant ->
710710
dependsOn "buildAppsec-${phpVersion}-${variant}"
711711
if (project.hasProperty('helperBinary')) {
712712
// Skip building helper-rust when explicit binary path is provided
713+
dependsOn createVolumeTask('php-helper-rust')
713714
} else if (project.hasProperty('useHelperRustCoverage')) {
714715
dependsOn 'buildHelperRustWithCoverage'
715716
} else if (project.hasProperty('useHelperRust')) {
716717
dependsOn 'buildHelperRust'
717718
} else if (phpVersion in ['8.4', '8.5']) {
718719
// PHP 8.4+ uses Rust helper by default via DD_APPSEC_HELPER_RUST_REDIRECTION
719720
dependsOn 'buildHelperRust'
721+
} else {
722+
// C++ helper path: test containers still mount php-helper-rust (for
723+
// the rust-redirection mechanism). Pre-create and chown the volume
724+
// here so Docker doesn't auto-create it as root-owned.
725+
dependsOn createVolumeTask('php-helper-rust')
720726
}
721727

722728
if (phpVersion in ['7.0', '7.1']) {

appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/TelemetryTests.groovy

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -730,19 +730,23 @@ class TelemetryTests {
730730
assert wafDurationExt.count >= 1.0
731731

732732
def span = trace[0]
733-
def durationMs = span.metrics.'_dd.appsec.waf.duration'
734-
assert durationMs != null && durationMs > 0.0d :
733+
def durationUs = span.metrics.'_dd.appsec.waf.duration'
734+
assert durationUs != null && durationUs > 0.0d :
735735
'_dd.appsec.waf.duration span metric must be > 0'
736-
def durationExtMs = span.metrics.'_dd.appsec.waf.duration_ext'
737-
assert durationExtMs != null && durationExtMs > 0.0d :
736+
def durationExtUs = span.metrics.'_dd.appsec.waf.duration_ext'
737+
assert durationExtUs != null && durationExtUs > 0.0d :
738738
'_dd.appsec.waf.duration_ext span metric must be > 0'
739739

740-
// Distributions are in µs; span metrics are in ms.
741-
assert wafDuration.countForBinContaining(durationMs * 1000.0) != null :
742-
"span metric value ${durationMs} ms (${durationMs * 1000.0} µs) not found in any " +
740+
assert durationExtUs >= durationUs :
741+
'_dd.appsec.waf.duration_ext must be >= .duration'
742+
743+
// Both waf.duration span metric and distribution are in µs.
744+
assert wafDuration.countForBinContaining(durationUs) != null :
745+
"span metric value ${durationUs} µs not found in any " +
743746
"waf.duration distribution bin; distribution: ${wafDuration}"
744-
assert wafDurationExt.countForBinContaining(durationExtMs * 1000.0) != null :
745-
"span metric value ${durationExtMs} ms (${durationExtMs * 1000.0} µs) not found in any " +
747+
// Both waf.duration_ext span metric and distribution are in µs.
748+
assert wafDurationExt.countForBinContaining(durationExtUs) != null :
749+
"span metric value ${durationExtUs} µs not found in any " +
746750
"waf.duration_ext distribution bin; distribution: ${wafDurationExt}"
747751
}
748752

@@ -965,16 +969,19 @@ class TelemetryTests {
965969
assert raspDurationExt.count >= 1.0
966970

967971
def span = trace[0]
968-
def raspDurationMs = span.metrics.'_dd.appsec.rasp.duration'
969-
assert raspDurationMs != null && raspDurationMs > 0.0d :
972+
def raspDurationUs = span.metrics.'_dd.appsec.rasp.duration'
973+
assert raspDurationUs != null && raspDurationUs > 0.0d :
970974
'_dd.appsec.rasp.duration span metric must be > 0'
971975
def raspDurationExtUs = span.metrics.'_dd.appsec.rasp.duration_ext'
972976
assert raspDurationExtUs != null && raspDurationExtUs > 0.0d :
973977
'_dd.appsec.rasp.duration_ext span metric must be > 0'
974978

975-
// rasp.duration distribution is in µs; the span metric is in ms.
976-
assert raspDuration.countForBinContaining(raspDurationMs * 1000.0) != null :
977-
"span metric value ${raspDurationMs} ms (${raspDurationMs * 1000.0} µs) not found in any " +
979+
assert raspDurationExtUs >= raspDurationUs :
980+
'_dd.appsec.rasp.duration_ext should be >= .duration'
981+
982+
// Both rasp.duration span metric and distribution are in µs.
983+
assert raspDuration.countForBinContaining(raspDurationUs) != null :
984+
"span metric value ${raspDurationUs} µs not found in any " +
978985
"rasp.duration distribution bin; distribution: ${raspDuration}"
979986

980987
// Both the span metric and the rasp.duration_ext distribution are in µs.

0 commit comments

Comments
 (0)