Skip to content

appsec: fix duration_ext metric#3507

Merged
cataphract merged 2 commits intomasterfrom
glopes/fix-duration_ext
Dec 5, 2025
Merged

appsec: fix duration_ext metric#3507
cataphract merged 2 commits intomasterfrom
glopes/fix-duration_ext

Conversation

@cataphract
Copy link
Copy Markdown
Contributor

It had three problems:

  • Value in ns instead of microseconds
  • It would effectively be the time of the first rasp call only
  • Did not fetch the span properly where to store the tags

Description

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 28, 2025

Codecov Report

❌ Patch coverage is 77.55102% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.63%. Comparing base (867b36c) to head (d10e448).
⚠️ Report is 329 commits behind head on master.

Files with missing lines Patch % Lines
appsec/src/extension/rasp.c 71.05% 8 Missing and 3 partials ⚠️

❌ Your patch status has failed because the patch coverage (77.55%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3507      +/-   ##
==========================================
- Coverage   61.74%   61.63%   -0.11%     
==========================================
  Files         142      143       +1     
  Lines       12975    13003      +28     
  Branches     1700     1702       +2     
==========================================
+ Hits         8011     8014       +3     
- Misses       4204     4228      +24     
- Partials      760      761       +1     
Files with missing lines Coverage Δ
appsec/src/extension/ddappsec.c 75.16% <100.00%> (+0.16%) ⬆️
appsec/src/extension/request_lifecycle.c 65.28% <100.00%> (+0.13%) ⬆️
appsec/src/extension/tags.c 80.34% <ø> (+0.07%) ⬆️
appsec/src/extension/tags.h 100.00% <ø> (ø)
appsec/src/extension/rasp.c 71.05% <71.05%> (ø)

... and 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 867b36c...d10e448. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

It had three problems:
* Value in ns instead of microseconds
* It would effectively be the time of the first rasp call only
* Did not fetch the span properly where to store the tags
@cataphract cataphract force-pushed the glopes/fix-duration_ext branch from 39b736b to be6b02a Compare November 28, 2025 11:39
@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented Nov 28, 2025

Benchmarks [ appsec ]

Benchmark execution time: 2025-12-03 16:50:55

Comparing candidate commit d10e448 in PR branch glopes/fix-duration_ext with baseline commit 867b36c in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 12 metrics, 0 unstable metrics.

@cataphract cataphract marked this pull request as ready for review December 3, 2025 16:14
@cataphract cataphract requested a review from a team as a code owner December 3, 2025 16:14
Comment on lines +49 to +66
static void _add_rasp_duration_ext_to_metrics(
zend_object *nonnull span, double duration)
{
zval *metrics_zv = dd_trace_span_get_metrics(span);
if (!metrics_zv) {
return;
}

zval zv;
ZVAL_DOUBLE(&zv, duration);
zval *nullable res =
zend_hash_add(Z_ARRVAL_P(metrics_zv), _dd_rasp_duration_ext, &zv);
if (res == NULL) {
mlog(dd_log_warning, "Failed to add metric %.*s",
(int)ZSTR_LEN(_dd_rasp_duration_ext),
ZSTR_VAL(_dd_rasp_duration_ext));
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep this part on tags.c since everything related to metrics is there. Just an opinion

@cataphract cataphract merged commit c52dcf1 into master Dec 5, 2025
2006 of 2008 checks passed
@cataphract cataphract deleted the glopes/fix-duration_ext branch December 5, 2025 12:33
@github-actions github-actions Bot added this to the 1.15.0 milestone Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants