Skip to content

Commit 3949350

Browse files
committed
fix(http): append path to the url
1 parent 7bdc7d6 commit 3949350

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

datadog_lambda/trigger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ def extract_http_tags(event):
315315
path = apigateway_v2_http.get("path")
316316
method = apigateway_v2_http.get("method")
317317

318-
if path:
319-
http_tags["http.url_details.path"] = path
318+
if path and http_tags.get("http.url"):
319+
http_tags["http.url"] += path
320320
if method:
321321
http_tags["http.method"] = method
322322

tests/test_trigger.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,7 @@ def test_extract_trigger_tags_api_gateway(self):
301301
{
302302
"function_trigger.event_source": "api-gateway",
303303
"function_trigger.event_source_arn": "arn:aws:apigateway:us-west-1::/restapis/1234567890/stages/prod",
304-
"http.url": "https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com",
305-
"http.url_details.path": "/prod/path/to/resource",
304+
"http.url": "https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/prod/path/to/resource",
306305
"http.method": "POST",
307306
"http.route": "/{proxy+}",
308307
},
@@ -320,8 +319,7 @@ def test_extract_trigger_tags_api_gateway_non_proxy(self):
320319
{
321320
"function_trigger.event_source": "api-gateway",
322321
"function_trigger.event_source_arn": "arn:aws:apigateway:us-west-1::/restapis/lgxbo6a518/stages/dev",
323-
"http.url": "https://lgxbo6a518.execute-api.eu-west-1.amazonaws.com",
324-
"http.url_details.path": "/dev/http/get",
322+
"http.url": "https://lgxbo6a518.execute-api.eu-west-1.amazonaws.com/dev/http/get",
325323
"http.method": "GET",
326324
"http.route": "/http/get",
327325
},
@@ -387,8 +385,7 @@ def test_extract_trigger_tags_api_gateway_http_api(self):
387385
{
388386
"function_trigger.event_source": "api-gateway",
389387
"function_trigger.event_source_arn": "arn:aws:apigateway:us-west-1::/restapis/x02yirxc7a/stages/$default",
390-
"http.url": "https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com",
391-
"http.url_details.path": "/httpapi/get",
388+
"http.url": "https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get",
392389
"http.method": "GET",
393390
"http.route": "/httpapi/get",
394391
},
@@ -406,7 +403,6 @@ def test_extract_trigger_tags_application_load_balancer(self):
406403
{
407404
"function_trigger.event_source": "application-load-balancer",
408405
"function_trigger.event_source_arn": "arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/lambda-xyz/123abc",
409-
"http.url_details.path": "/lambda",
410406
"http.method": "GET",
411407
},
412408
)
@@ -568,9 +564,7 @@ def test_extract_http_tags_with_invalid_request_context(self):
568564
event = {"requestContext": "not_a_dict", "path": "/test", "httpMethod": "GET"}
569565
http_tags = extract_http_tags(event)
570566
# Should still extract valid tags from the event
571-
self.assertEqual(
572-
http_tags, {"http.url_details.path": "/test", "http.method": "GET"}
573-
)
567+
self.assertEqual(http_tags, {"http.method": "GET"})
574568

575569
def test_extract_http_tags_with_invalid_apigateway_http(self):
576570
from datadog_lambda.trigger import extract_http_tags

0 commit comments

Comments
 (0)