From 6117d295fa680fed35108a12227934629c49097e Mon Sep 17 00:00:00 2001 From: Florentin Labelle Date: Thu, 9 Oct 2025 11:47:41 +0200 Subject: [PATCH] fix(http): http.url tag should contain the path --- datadog_lambda/trigger.py | 3 ++- .../snapshots/logs/async-metrics_python310.log | 6 ++---- .../snapshots/logs/async-metrics_python311.log | 6 ++---- .../snapshots/logs/async-metrics_python312.log | 6 ++---- .../snapshots/logs/async-metrics_python313.log | 6 ++---- .../snapshots/logs/async-metrics_python38.log | 6 ++---- .../snapshots/logs/async-metrics_python39.log | 6 ++---- .../snapshots/logs/sync-metrics_python310.log | 6 ++---- .../snapshots/logs/sync-metrics_python311.log | 6 ++---- .../snapshots/logs/sync-metrics_python312.log | 6 ++---- .../snapshots/logs/sync-metrics_python313.log | 6 ++---- .../snapshots/logs/sync-metrics_python38.log | 6 ++---- .../snapshots/logs/sync-metrics_python39.log | 6 ++---- tests/test_trigger.py | 11 +++-------- 14 files changed, 29 insertions(+), 57 deletions(-) diff --git a/datadog_lambda/trigger.py b/datadog_lambda/trigger.py index e0c3c4fa..e60de8f0 100644 --- a/datadog_lambda/trigger.py +++ b/datadog_lambda/trigger.py @@ -325,7 +325,8 @@ def extract_http_tags(event): method = apigateway_v2_http.get("method") if path: - http_tags["http.url_details.path"] = path + if http_tags.get("http.url"): + http_tags["http.url"] += path if method: http_tags["http.method"] = method diff --git a/tests/integration/snapshots/logs/async-metrics_python310.log b/tests/integration/snapshots/logs/async-metrics_python310.log index ea8bf42f..6779d7dd 100644 --- a/tests/integration/snapshots/logs/async-metrics_python310.log +++ b/tests/integration/snapshots/logs/async-metrics_python310.log @@ -105,8 +105,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.us-east-2.amazonaws.com/Prod/", "http.method": "GET", "http.route": "/", "http.status_code": "200" @@ -772,8 +771,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com/httpapi/get", "http.method": "GET", "http.route": "/httpapi/get", "http.status_code": "200" diff --git a/tests/integration/snapshots/logs/async-metrics_python311.log b/tests/integration/snapshots/logs/async-metrics_python311.log index 5aa9c554..9f14ff15 100644 --- a/tests/integration/snapshots/logs/async-metrics_python311.log +++ b/tests/integration/snapshots/logs/async-metrics_python311.log @@ -105,8 +105,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.us-east-2.amazonaws.com/Prod/", "http.method": "GET", "http.route": "/", "http.status_code": "200" @@ -772,8 +771,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com/httpapi/get", "http.method": "GET", "http.route": "/httpapi/get", "http.status_code": "200" diff --git a/tests/integration/snapshots/logs/async-metrics_python312.log b/tests/integration/snapshots/logs/async-metrics_python312.log index 67732da6..789a3955 100644 --- a/tests/integration/snapshots/logs/async-metrics_python312.log +++ b/tests/integration/snapshots/logs/async-metrics_python312.log @@ -105,8 +105,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.us-east-2.amazonaws.com/Prod/", "http.method": "GET", "http.route": "/", "http.status_code": "200" @@ -772,8 +771,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com/httpapi/get", "http.method": "GET", "http.route": "/httpapi/get", "http.status_code": "200" diff --git a/tests/integration/snapshots/logs/async-metrics_python313.log b/tests/integration/snapshots/logs/async-metrics_python313.log index 18b3109e..78ade6a7 100644 --- a/tests/integration/snapshots/logs/async-metrics_python313.log +++ b/tests/integration/snapshots/logs/async-metrics_python313.log @@ -105,8 +105,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.us-east-2.amazonaws.com/Prod/", "http.method": "GET", "http.route": "/", "http.status_code": "200" @@ -772,8 +771,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com/httpapi/get", "http.method": "GET", "http.route": "/httpapi/get", "http.status_code": "200" diff --git a/tests/integration/snapshots/logs/async-metrics_python38.log b/tests/integration/snapshots/logs/async-metrics_python38.log index c9fe147f..5375fafe 100644 --- a/tests/integration/snapshots/logs/async-metrics_python38.log +++ b/tests/integration/snapshots/logs/async-metrics_python38.log @@ -105,8 +105,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.us-east-2.amazonaws.com/Prod/", "http.method": "GET", "http.route": "/", "http.status_code": "200" @@ -772,8 +771,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com/httpapi/get", "http.method": "GET", "http.route": "/httpapi/get", "http.status_code": "200" diff --git a/tests/integration/snapshots/logs/async-metrics_python39.log b/tests/integration/snapshots/logs/async-metrics_python39.log index 47fd9c87..f16e9e2d 100644 --- a/tests/integration/snapshots/logs/async-metrics_python39.log +++ b/tests/integration/snapshots/logs/async-metrics_python39.log @@ -105,8 +105,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.us-east-2.amazonaws.com/Prod/", "http.method": "GET", "http.route": "/", "http.status_code": "200" @@ -772,8 +771,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com/httpapi/get", "http.method": "GET", "http.route": "/httpapi/get", "http.status_code": "200" diff --git a/tests/integration/snapshots/logs/sync-metrics_python310.log b/tests/integration/snapshots/logs/sync-metrics_python310.log index 1e1b8a7b..1cbd91dd 100644 --- a/tests/integration/snapshots/logs/sync-metrics_python310.log +++ b/tests/integration/snapshots/logs/sync-metrics_python310.log @@ -85,8 +85,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.us-east-2.amazonaws.com/Prod/", "http.method": "GET", "http.route": "/", "http.status_code": "200" @@ -828,8 +827,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com/httpapi/get", "http.method": "GET", "http.route": "/httpapi/get", "http.status_code": "200" diff --git a/tests/integration/snapshots/logs/sync-metrics_python311.log b/tests/integration/snapshots/logs/sync-metrics_python311.log index adc6d215..b043a8f4 100644 --- a/tests/integration/snapshots/logs/sync-metrics_python311.log +++ b/tests/integration/snapshots/logs/sync-metrics_python311.log @@ -85,8 +85,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.us-east-2.amazonaws.com/Prod/", "http.method": "GET", "http.route": "/", "http.status_code": "200" @@ -828,8 +827,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com/httpapi/get", "http.method": "GET", "http.route": "/httpapi/get", "http.status_code": "200" diff --git a/tests/integration/snapshots/logs/sync-metrics_python312.log b/tests/integration/snapshots/logs/sync-metrics_python312.log index a7934c86..ff9bbdb7 100644 --- a/tests/integration/snapshots/logs/sync-metrics_python312.log +++ b/tests/integration/snapshots/logs/sync-metrics_python312.log @@ -85,8 +85,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.us-east-2.amazonaws.com/Prod/", "http.method": "GET", "http.route": "/", "http.status_code": "200" @@ -828,8 +827,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com/httpapi/get", "http.method": "GET", "http.route": "/httpapi/get", "http.status_code": "200" diff --git a/tests/integration/snapshots/logs/sync-metrics_python313.log b/tests/integration/snapshots/logs/sync-metrics_python313.log index a5516973..87352f25 100644 --- a/tests/integration/snapshots/logs/sync-metrics_python313.log +++ b/tests/integration/snapshots/logs/sync-metrics_python313.log @@ -85,8 +85,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.us-east-2.amazonaws.com/Prod/", "http.method": "GET", "http.route": "/", "http.status_code": "200" @@ -828,8 +827,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com/httpapi/get", "http.method": "GET", "http.route": "/httpapi/get", "http.status_code": "200" diff --git a/tests/integration/snapshots/logs/sync-metrics_python38.log b/tests/integration/snapshots/logs/sync-metrics_python38.log index 8cd4eb2c..ae41bc18 100644 --- a/tests/integration/snapshots/logs/sync-metrics_python38.log +++ b/tests/integration/snapshots/logs/sync-metrics_python38.log @@ -85,8 +85,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.us-east-2.amazonaws.com/Prod/", "http.method": "GET", "http.route": "/", "http.status_code": "200" @@ -828,8 +827,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com/httpapi/get", "http.method": "GET", "http.route": "/httpapi/get", "http.status_code": "200" diff --git a/tests/integration/snapshots/logs/sync-metrics_python39.log b/tests/integration/snapshots/logs/sync-metrics_python39.log index 5e5e9cf3..1acb7f0d 100644 --- a/tests/integration/snapshots/logs/sync-metrics_python39.log +++ b/tests/integration/snapshots/logs/sync-metrics_python39.log @@ -85,8 +85,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.us-east-2.amazonaws.com/Prod/", "http.method": "GET", "http.route": "/", "http.status_code": "200" @@ -828,8 +827,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A "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.url": "https://XXXX.execute-api.eu-west-1.amazonaws.com/httpapi/get", "http.method": "GET", "http.route": "/httpapi/get", "http.status_code": "200" diff --git a/tests/test_trigger.py b/tests/test_trigger.py index 182e61d8..f10fcbbf 100644 --- a/tests/test_trigger.py +++ b/tests/test_trigger.py @@ -318,8 +318,7 @@ def test_extract_trigger_tags_api_gateway(self): { "function_trigger.event_source": "api-gateway", "function_trigger.event_source_arn": "arn:aws:apigateway:us-west-1::/restapis/1234567890/stages/prod", - "http.url": "https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com", - "http.url_details.path": "/prod/path/to/resource", + "http.url": "https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/prod/path/to/resource", "http.method": "POST", "http.route": "/{proxy+}", "span.kind": "server", @@ -338,8 +337,7 @@ def test_extract_trigger_tags_api_gateway_non_proxy(self): { "function_trigger.event_source": "api-gateway", "function_trigger.event_source_arn": "arn:aws:apigateway:us-west-1::/restapis/lgxbo6a518/stages/dev", - "http.url": "https://lgxbo6a518.execute-api.eu-west-1.amazonaws.com", - "http.url_details.path": "/dev/http/get", + "http.url": "https://lgxbo6a518.execute-api.eu-west-1.amazonaws.com/dev/http/get", "http.method": "GET", "http.route": "/http/get", "span.kind": "server", @@ -409,8 +407,7 @@ def test_extract_trigger_tags_api_gateway_http_api(self): { "function_trigger.event_source": "api-gateway", "function_trigger.event_source_arn": "arn:aws:apigateway:us-west-1::/restapis/x02yirxc7a/stages/$default", - "http.url": "https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com", - "http.url_details.path": "/httpapi/get", + "http.url": "https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", "http.method": "GET", "span.kind": "server", "http.route": "/httpapi/get", @@ -429,7 +426,6 @@ def test_extract_trigger_tags_application_load_balancer(self): { "function_trigger.event_source": "application-load-balancer", "function_trigger.event_source_arn": "arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/lambda-xyz/123abc", - "http.url_details.path": "/lambda", "http.method": "GET", "span.kind": "server", }, @@ -596,7 +592,6 @@ def test_extract_http_tags_with_invalid_request_context(self): http_tags, { "span.kind": "server", - "http.url_details.path": "/test", "http.method": "GET", }, )