Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions datadog_lambda/asm.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,6 +44,16 @@ def _merge_single_and_multi_value_headers(
return _to_single_value_headers(merged_headers)


def asm_set_context(event_source: _EventSource):
"""Add asm specific items to the ExecutionContext.

This allows the AppSecSpanProcessor to know information about the event
at the moment the span is created and skip it when not relevant.
"""
if event_source.event_type not in _http_event_types:
core.set_item("appsec_skip_next_lambda_event", True)


def asm_start_request(
span: Span,
event: Dict[str, Any],
Expand Down
6 changes: 5 additions & 1 deletion datadog_lambda/wrapper.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@
from importlib import import_module
from time import time_ns

from datadog_lambda.asm import asm_start_response, asm_start_request
from datadog_lambda.asm import asm_set_context, asm_start_response, asm_start_request
from datadog_lambda.dsm import set_dsm_context
from datadog_lambda.extension import should_use_extension, flush_extension
from datadog_lambda.cold_start import (
Expand DownExpand Up@@ -239,6 +239,10 @@ def _before(self, event, context):
)
if config.data_streams_enabled:
set_dsm_context(event, event_source)

if config.appsec_enabled:
asm_set_context(event_source)

self.span = create_function_execution_span(
context=context,
function_name=config.function_name,
Expand Down
Loading