Skip to content

Add telemetry metrics for API Security schema extraction#5340

Open
y9v wants to merge 11 commits intomasterfrom
appsec-api-security-schema-telemetry
Open

Add telemetry metrics for API Security schema extraction#5340
y9v wants to merge 11 commits intomasterfrom
appsec-api-security-schema-telemetry

Conversation

@y9v
Copy link
Member

@y9v y9v commented Feb 10, 2026

What does this PR do?
This PR adds reporting of appsec.api_security.request.schema and appsec.api_security.request.no_schema telemetry. One of those metrics must be reported depending of whether the schema was successfully extracted or not.

Motivation:
We want to report more telemetry metrics for AppSec.

Change log entry
None.

Additional Notes:
APPSEC-60123

How to test the change?
CI

@y9v y9v self-assigned this Feb 10, 2026
@y9v y9v requested a review from a team as a code owner February 10, 2026 11:13
@github-actions github-actions bot added integrations Involves tracing integrations appsec Application Security monitoring product labels Feb 10, 2026
@datadog-official
Copy link

datadog-official bot commented Feb 10, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 84.62%
Overall Coverage: 95.10%

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ec69065 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@pr-commenter
Copy link

pr-commenter bot commented Feb 10, 2026

Benchmarks

Benchmark execution time: 2026-02-13 14:17:06

Comparing candidate commit ec69065 in PR branch appsec-api-security-schema-telemetry with baseline commit 4f22dac in branch master.

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

Copy link
Member

@Strech Strech left a comment

Choose a reason for hiding this comment

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

After discussion we come to the conclusion that some refactoring needed:

  1. Update extract schema method to mutate events without disclosing event itself
  2. Metric should be counted on schema extraction
  3. Absence of the counted metric (via state or other) tracked and added on the metrics export as "no schema"

@y9v y9v force-pushed the appsec-api-security-schema-telemetry branch from a9478d7 to 8197e57 Compare February 11, 2026 19:59
@y9v y9v requested a review from a team as a code owner February 11, 2026 19:59
@github-actions
Copy link

github-actions bot commented Feb 11, 2026

Typing analysis

Note: Ignored files are excluded from the next sections.

steep:ignore comments

This PR introduces 1 steep:ignore comment, and clears 1 steep:ignore comment.

steep:ignore comments (+1-1)Introduced:
lib/datadog/appsec/context.rb:20
Cleared:
lib/datadog/appsec/context.rb:19

@y9v y9v requested a review from Strech February 11, 2026 20:03
Copy link
Member

@Strech Strech left a comment

Choose a reason for hiding this comment

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

A solid change 👍🏼

@y9v y9v force-pushed the appsec-api-security-schema-telemetry branch from 4ab4b28 to ec69065 Compare February 13, 2026 13:46
Comment on lines +125 to +128
Metrics::TelemetryExporter.export_api_security_metrics(
schema_extracted: !!@state[:schema_extracted],
web_framework: @state[:web_framework]
)
Copy link
Member

Choose a reason for hiding this comment

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

There is also an option to give entire @state and exporter will figure it out, so we encapsulate it there

Copy link
Member Author

Choose a reason for hiding this comment

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

this depends on how much we want the telemetry exporter to know about the context state. Probably it's ok?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

appsec Application Security monitoring product integrations Involves tracing integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants