diff --git a/integration_tests/snapshots/logs/process-input-traced_node16.log b/integration_tests/snapshots/logs/process-input-traced_node16.log index 5734dc9bf..6c2c21517 100644 --- a/integration_tests/snapshots/logs/process-input-traced_node16.log +++ b/integration_tests/snapshots/logs/process-input-traced_node16.log @@ -48,6 +48,7 @@ START "_inferred_span.tag_source": "self", "_inferred_span.synchronicity": "sync", "http.method": "GET", + "http.route":"/{proxy+}", "stage": "test", "http.status_code": "200", "_dd.base_service": "integration-tests-js-XXXX-process-input-traced_node16", diff --git a/integration_tests/snapshots/logs/process-input-traced_node18.log b/integration_tests/snapshots/logs/process-input-traced_node18.log index bdee824ca..f38d929c2 100644 --- a/integration_tests/snapshots/logs/process-input-traced_node18.log +++ b/integration_tests/snapshots/logs/process-input-traced_node18.log @@ -48,6 +48,7 @@ START "_inferred_span.tag_source": "self", "_inferred_span.synchronicity": "sync", "http.method": "GET", + "http.route":"/{proxy+}", "stage": "test", "http.status_code": "200", "_dd.base_service": "integration-tests-js-XXXX-process-input-traced_node18", diff --git a/integration_tests/snapshots/logs/process-input-traced_node20.log b/integration_tests/snapshots/logs/process-input-traced_node20.log index e04b7a03d..dfc45ae7c 100644 --- a/integration_tests/snapshots/logs/process-input-traced_node20.log +++ b/integration_tests/snapshots/logs/process-input-traced_node20.log @@ -48,6 +48,7 @@ START "_inferred_span.tag_source": "self", "_inferred_span.synchronicity": "sync", "http.method": "GET", + "http.route":"/{proxy+}", "stage": "test", "http.status_code": "200", "_dd.base_service": "integration-tests-js-XXXX-process-input-traced_node20", diff --git a/integration_tests/snapshots/logs/status-code-500s_node16.log b/integration_tests/snapshots/logs/status-code-500s_node16.log index 9662d57e2..79f4a0c8d 100644 --- a/integration_tests/snapshots/logs/status-code-500s_node16.log +++ b/integration_tests/snapshots/logs/status-code-500s_node16.log @@ -54,6 +54,7 @@ START "_inferred_span.tag_source": "self", "_inferred_span.synchronicity": "sync", "http.method": "GET", + "http.route":"/{proxy+}", "stage": "test", "http.status_code": "500", "_dd.base_service": "integration-tests-js-XXXX-status-code-500s_node16", diff --git a/integration_tests/snapshots/logs/status-code-500s_node18.log b/integration_tests/snapshots/logs/status-code-500s_node18.log index f8a31bee3..7248a341a 100644 --- a/integration_tests/snapshots/logs/status-code-500s_node18.log +++ b/integration_tests/snapshots/logs/status-code-500s_node18.log @@ -54,6 +54,7 @@ START "_inferred_span.tag_source": "self", "_inferred_span.synchronicity": "sync", "http.method": "GET", + "http.route":"/{proxy+}", "stage": "test", "http.status_code": "500", "_dd.base_service": "integration-tests-js-XXXX-status-code-500s_node18", diff --git a/integration_tests/snapshots/logs/status-code-500s_node20.log b/integration_tests/snapshots/logs/status-code-500s_node20.log index 8a0c50b31..938aec864 100644 --- a/integration_tests/snapshots/logs/status-code-500s_node20.log +++ b/integration_tests/snapshots/logs/status-code-500s_node20.log @@ -54,6 +54,7 @@ START "_inferred_span.tag_source": "self", "_inferred_span.synchronicity": "sync", "http.method": "GET", + "http.route":"/{proxy+}", "stage": "test", "http.status_code": "500", "_dd.base_service": "integration-tests-js-XXXX-status-code-500s_node20", diff --git a/src/trace/trigger.spec.ts b/src/trace/trigger.spec.ts index 471e363f5..29b648921 100644 --- a/src/trace/trigger.spec.ts +++ b/src/trace/trigger.spec.ts @@ -17,6 +17,7 @@ describe("parseEventSource", () => { "http.url": "id.execute-api.us-east-1.amazonaws.com", "http.url_details.path": "/my/path", "http.method": "GET", + "http.route": "/my/path", }, file: "api-gateway-v1.json", }, @@ -27,6 +28,7 @@ describe("parseEventSource", () => { "http.url": "r3pmxmplak.execute-api.us-east-2.amazonaws.com", "http.url_details.path": "/default/nodejs-apig-function-1G3XMPLZXVXYI", "http.method": "GET", + "http.route": "/nodejs-apig-function-1G3XMPLZXVXYI", }, file: "api-gateway-v2.json", }, diff --git a/src/trace/trigger.ts b/src/trace/trigger.ts index ab6700593..e23e0fb6a 100644 --- a/src/trace/trigger.ts +++ b/src/trace/trigger.ts @@ -275,6 +275,9 @@ function extractHTTPTags(event: APIGatewayEvent | APIGatewayProxyEventV2 | ALBEv if (event.headers?.Referer) { httpTags["http.referer"] = event.headers.Referer; } + if (event.resource) { + httpTags["http.route"] = event.resource; + } return httpTags; } @@ -286,6 +289,11 @@ function extractHTTPTags(event: APIGatewayEvent | APIGatewayProxyEventV2 | ALBEv if (event.headers?.Referer) { httpTags["http.referer"] = event.headers.Referer; } + if (event.routeKey) { + // "GET /my/endpoint" => "/my/endpoint" + const array = event.routeKey.split(" "); + httpTags["http.route"] = array[array.length - 1]; + } return httpTags; }