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
2 changes: 0 additions & 2 deletions datadog_lambda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
"DD_APPSEC_ENABLED", "false"
)

if os.environ.get("DD_API_SECURITY_ENABLED") is None:
os.environ["DD_API_SECURITY_ENABLED"] = "False"
Copy link
Contributor

Choose a reason for hiding this comment

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

@florentinl question: what does the DD_API_SECURITY_ENABLED env var do? What impact will there be from removing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This env controls the enablement of the API Security feature of Appsec. It extracts the schema of the request and runs additional security rules.
On all tracers, it is enabled by default and discussing it with the security ecosystems team there is no reason to change the default for lambda.

Of course, this feature is a sub feature of Appsec and is automatically disabled when DD_APPSEC_ENABLED is not set to a truthy value (see APIManager enablement in dd-trace-py)


initialize_cold_start_tracing()

Expand Down
2 changes: 1 addition & 1 deletion datadog_lambda/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def extract_http_tags(event):
"""
Extracts HTTP facet tags from the triggering event
"""
http_tags = {}
http_tags = {"span.kind": "server"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch, I originally made changes to add this tag to all the related synthetic spans but missed it on the actual aws.lambda span. Is there a plan on the roadmap for getting this done in the Node Layer and the Rust extension as well?

Copy link
Contributor Author

@florentinl florentinl Sep 2, 2025

Choose a reason for hiding this comment

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

Nothing formally planned yet. But we are interested in having it across all lambda layers to fix API Security in lambda (already available through the go and now rust extension).
I can look into it, if you want.


# Safely get request_context and ensure it's a dictionary
request_context = event.get("requestContext")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.us-east-2.amazonaws.com",
"http.url_details.path": "/Prod/",
"http.method": "GET",
Expand Down Expand Up @@ -642,6 +643,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX$default",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.url_details.path": "/httpapi/get",
"http.method": "GET",
Expand Down Expand Up @@ -1479,6 +1481,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.status_code": "200"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.us-east-2.amazonaws.com",
"http.url_details.path": "/Prod/",
"http.method": "GET",
Expand Down Expand Up @@ -642,6 +643,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX$default",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.url_details.path": "/httpapi/get",
"http.method": "GET",
Expand Down Expand Up @@ -1479,6 +1481,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.status_code": "200"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.us-east-2.amazonaws.com",
"http.url_details.path": "/Prod/",
"http.method": "GET",
Expand Down Expand Up @@ -642,6 +643,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX$default",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.url_details.path": "/httpapi/get",
"http.method": "GET",
Expand Down Expand Up @@ -1479,6 +1481,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.status_code": "200"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.us-east-2.amazonaws.com",
"http.url_details.path": "/Prod/",
"http.method": "GET",
Expand Down Expand Up @@ -642,6 +643,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX$default",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.url_details.path": "/httpapi/get",
"http.method": "GET",
Expand Down Expand Up @@ -1479,6 +1481,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.status_code": "200"
},
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/snapshots/logs/async-metrics_python38.log
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.us-east-2.amazonaws.com",
"http.url_details.path": "/Prod/",
"http.method": "GET",
Expand Down Expand Up @@ -642,6 +643,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX$default",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.url_details.path": "/httpapi/get",
"http.method": "GET",
Expand Down Expand Up @@ -1479,6 +1481,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.status_code": "200"
},
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/snapshots/logs/async-metrics_python39.log
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.us-east-2.amazonaws.com",
"http.url_details.path": "/Prod/",
"http.method": "GET",
Expand Down Expand Up @@ -642,6 +643,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX$default",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.url_details.path": "/httpapi/get",
"http.method": "GET",
Expand Down Expand Up @@ -1479,6 +1481,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.status_code": "200"
},
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/snapshots/logs/sync-metrics_python310.log
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.us-east-2.amazonaws.com",
"http.url_details.path": "/Prod/",
"http.method": "GET",
Expand Down Expand Up @@ -679,6 +680,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX$default",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.url_details.path": "/httpapi/get",
"http.method": "GET",
Expand Down Expand Up @@ -1611,6 +1613,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.status_code": "200"
},
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/snapshots/logs/sync-metrics_python311.log
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.us-east-2.amazonaws.com",
"http.url_details.path": "/Prod/",
"http.method": "GET",
Expand Down Expand Up @@ -679,6 +680,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX$default",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.url_details.path": "/httpapi/get",
"http.method": "GET",
Expand Down Expand Up @@ -1611,6 +1613,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.status_code": "200"
},
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/snapshots/logs/sync-metrics_python312.log
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.us-east-2.amazonaws.com",
"http.url_details.path": "/Prod/",
"http.method": "GET",
Expand Down Expand Up @@ -679,6 +680,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX$default",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.url_details.path": "/httpapi/get",
"http.method": "GET",
Expand Down Expand Up @@ -1611,6 +1613,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.status_code": "200"
},
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/snapshots/logs/sync-metrics_python313.log
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.us-east-2.amazonaws.com",
"http.url_details.path": "/Prod/",
"http.method": "GET",
Expand Down Expand Up @@ -679,6 +680,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX$default",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.url_details.path": "/httpapi/get",
"http.method": "GET",
Expand Down Expand Up @@ -1611,6 +1613,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.status_code": "200"
},
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/snapshots/logs/sync-metrics_python38.log
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.us-east-2.amazonaws.com",
"http.url_details.path": "/Prod/",
"http.method": "GET",
Expand Down Expand Up @@ -679,6 +680,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX$default",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.url_details.path": "/httpapi/get",
"http.method": "GET",
Expand Down Expand Up @@ -1611,6 +1613,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.status_code": "200"
},
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/snapshots/logs/sync-metrics_python39.log
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.us-east-2.amazonaws.com",
"http.url_details.path": "/Prod/",
"http.method": "GET",
Expand Down Expand Up @@ -679,6 +680,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX$default",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.url_details.path": "/httpapi/get",
"http.method": "GET",
Expand Down Expand Up @@ -1611,6 +1613,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"span.name": "aws.lambda",
"function_trigger.event_source": "api-gateway",
"function_trigger.event_source_arn": "XXXX",
"span.kind": "server",
"http.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com",
"http.status_code": "200"
},
Expand Down
Loading
Loading