Skip to content

Commit d71e9af

Browse files
committed
feat(appsec): add metric for unsupported lambda event types
1 parent 8d3e778 commit d71e9af

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

ddtrace/appsec/_constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class APPSEC(metaclass=Constant_Class):
121121
RASP_ERROR: Literal["_dd.appsec.rasp.error"] = "_dd.appsec.rasp.error"
122122
ERROR_TYPE: Literal["_dd.appsec.error.type"] = "_dd.appsec.error.type"
123123
ERROR_MESSAGE: Literal["_dd.appsec.error.message"] = "_dd.appsec.error.message"
124+
UNSUPPORTED_EVENT_TYPE: Literal["_dd.appsec.unsupported_event_type"] = "_dd.appsec.unsupported_event_type"
124125

125126

126127
TELEMETRY_OFF_NAME = "OFF"

ddtrace/appsec/_processor.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
from typing import Tuple
1515
from typing import Union
1616

17+
from ddtrace.ext import SpanTypes
18+
from ddtrace.internal import core
19+
1720

1821
if TYPE_CHECKING:
1922
import ddtrace.appsec._ddwaf as ddwaf
@@ -181,6 +184,16 @@ def on_span_start(self, span: Span) -> None:
181184
if span.span_type not in asm_config._asm_processed_span_types:
182185
return
183186

187+
if span.span_type == SpanTypes.SERVERLESS:
188+
skip_event = core.get_item("asm_skip_next_lambda_event")
189+
if skip_event:
190+
core.discard_item("asm_skip_next_lambda_event")
191+
log.debug(
192+
"appsec: ignoring unsupported lamdba event",
193+
)
194+
span.set_metric(APPSEC.UNSUPPORTED_EVENT_TYPE, 1.0)
195+
return
196+
184197
ctx = self._ddwaf._at_request_start()
185198
_asm_request_context.start_context(span, ctx.rc_products if ctx is not None else "")
186199
peer_ip = _asm_request_context.get_ip()

0 commit comments

Comments
 (0)