Skip to content

feat(appsec): add metric for unsupported lambda event types #13855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

florentinl
Copy link
Contributor

@florentinl florentinl commented Jul 2, 2025

Motivation

Avoid billing when Appsec is enabled for unsupported lambda events. To keep track of executions with unsupported events, we add a span metric.

Changes

  • Selectively skip processing the span based on the event

To make the information available, I used the same pattern as the asm context initialization by storing temporary information inside the ExecutionContext.

The only difference is that in the case of lambda we only have a single global ExecutionContext so we have to clean it up.

Notes

This PR relies on: DataDog/datadog-lambda-python#627

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

@florentinl florentinl requested a review from a team as a code owner July 2, 2025 12:07
@florentinl florentinl added ASM Application Security Monitoring changelog/no-changelog A changelog entry is not required for this PR. labels Jul 2, 2025
Copy link
Contributor

github-actions bot commented Jul 2, 2025

CODEOWNERS have been resolved as:

ddtrace/appsec/_constants.py                                            @DataDog/asm-python
ddtrace/appsec/_processor.py                                            @DataDog/asm-python
ddtrace/settings/asm.py                                                 @DataDog/asm-python
tests/appsec/appsec/test_processor.py                                   @DataDog/asm-python
tests/appsec/utils.py                                                   @DataDog/asm-python

Copy link
Contributor

github-actions bot commented Jul 2, 2025

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

The average import time from this PR is: 276 ± 3 ms.

The average import time from base is: 278 ± 2 ms.

The import time difference between this PR and base is: -2.2 ± 0.1 ms.

Import time breakdown

The following import paths have shrunk:

ddtrace.auto 1.999 ms (0.72%)
ddtrace.bootstrap.sitecustomize 1.321 ms (0.48%)
ddtrace.bootstrap.preload 1.321 ms (0.48%)
ddtrace.internal.remoteconfig.client 0.661 ms (0.24%)
ddtrace 0.678 ms (0.25%)
ddtrace.internal._unpatched 0.032 ms (0.01%)
json 0.032 ms (0.01%)
json.decoder 0.032 ms (0.01%)
re 0.032 ms (0.01%)
enum 0.032 ms (0.01%)
types 0.032 ms (0.01%)

@florentinl florentinl force-pushed the florentinl/APPSEC-58145/bill-only-supported-events branch from c7ddb8d to f1333c7 Compare July 2, 2025 12:32
@florentinl florentinl marked this pull request as draft July 2, 2025 12:32
@pr-commenter
Copy link

pr-commenter bot commented Jul 2, 2025

Benchmarks

Benchmark execution time: 2025-07-03 13:37:26

Comparing candidate commit eac244e in PR branch florentinl/APPSEC-58145/bill-only-supported-events with baseline commit 40bfbe4 in branch main.

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

scenario:iastaspects-strip_aspect

  • 🟥 execution_time [+748.378ns; +815.235ns] or [+7.185%; +7.827%]

scenario:telemetryaddmetric-1-distribution-metric-1-times

  • 🟥 execution_time [+411.373ns; +446.152ns] or [+14.138%; +15.333%]

@florentinl florentinl force-pushed the florentinl/APPSEC-58145/bill-only-supported-events branch from f1333c7 to ef1d128 Compare July 2, 2025 13:33
@florentinl florentinl marked this pull request as ready for review July 2, 2025 13:34
@florentinl florentinl force-pushed the florentinl/APPSEC-58145/bill-only-supported-events branch from ef1d128 to 5535a85 Compare July 3, 2025 12:18
@florentinl florentinl force-pushed the florentinl/APPSEC-58145/bill-only-supported-events branch from 5535a85 to eac244e Compare July 3, 2025 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASM Application Security Monitoring changelog/no-changelog A changelog entry is not required for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants