Skip to content

Commit e4bdd73

Browse files
authored
fix(http): http.url tag should contain the path (#742)
* set full url in http.url tag * trigger CI
1 parent c1c6ab2 commit e4bdd73

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

src/trace/trigger.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe("parseEventSource", () => {
1414
result: {
1515
"function_trigger.event_source": "api-gateway",
1616
"function_trigger.event_source_arn": "arn:aws:apigateway:us-east-1::/restapis/id/stages/$default",
17-
"http.url": "https://id.execute-api.us-east-1.amazonaws.com",
17+
"http.url": "https://id.execute-api.us-east-1.amazonaws.com/my/path",
1818
"http.url_details.path": "/my/path",
1919
"http.method": "GET",
2020
"http.route": "/my/path",
@@ -25,7 +25,7 @@ describe("parseEventSource", () => {
2525
result: {
2626
"function_trigger.event_source": "api-gateway",
2727
"function_trigger.event_source_arn": "arn:aws:apigateway:us-east-1::/restapis/r3pmxmplak/stages/default",
28-
"http.url": "https://r3pmxmplak.execute-api.us-east-2.amazonaws.com",
28+
"http.url": "https://r3pmxmplak.execute-api.us-east-2.amazonaws.com/default/nodejs-apig-function-1G3XMPLZXVXYI",
2929
"http.url_details.path": "/default/nodejs-apig-function-1G3XMPLZXVXYI",
3030
"http.method": "GET",
3131
"http.route": "/nodejs-apig-function-1G3XMPLZXVXYI",
@@ -35,7 +35,7 @@ describe("parseEventSource", () => {
3535
{
3636
result: {
3737
"function_trigger.event_source": "lambda-function-url",
38-
"http.url": "https://a8hyhsshac.lambda-url.eu-south-1.amazonaws.com",
38+
"http.url": "https://a8hyhsshac.lambda-url.eu-south-1.amazonaws.com/",
3939
"http.url_details.path": "/",
4040
"http.method": "GET",
4141
},

src/trace/trigger.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,11 @@ function extractHTTPTags(event: APIGatewayEvent | APIGatewayProxyEventV2 | ALBEv
288288

289289
if (eventType.isAPIGatewayEvent(event)) {
290290
const requestContext = event.requestContext;
291+
const path = requestContext.path;
291292
if (requestContext.domainName) {
292-
httpTags["http.url"] = `https://${requestContext.domainName}`;
293+
httpTags["http.url"] = `https://${requestContext.domainName}${path ?? ""}`;
293294
}
294-
httpTags["http.url_details.path"] = requestContext.path;
295+
httpTags["http.url_details.path"] = path;
295296
httpTags["http.method"] = requestContext.httpMethod;
296297
if (event.headers?.Referer) {
297298
httpTags["http.referer"] = event.headers.Referer;
@@ -304,8 +305,9 @@ function extractHTTPTags(event: APIGatewayEvent | APIGatewayProxyEventV2 | ALBEv
304305

305306
if (eventType.isAPIGatewayEventV2(event)) {
306307
const requestContext = event.requestContext;
307-
httpTags["http.url"] = `https://${requestContext.domainName}`;
308-
httpTags["http.url_details.path"] = requestContext.http.path;
308+
const path = requestContext.http.path;
309+
httpTags["http.url"] = `https://${requestContext.domainName}${path ?? ""}`;
310+
httpTags["http.url_details.path"] = path;
309311
httpTags["http.method"] = requestContext.http.method;
310312
if (event.headers?.Referer) {
311313
httpTags["http.referer"] = event.headers.Referer;
@@ -329,10 +331,11 @@ function extractHTTPTags(event: APIGatewayEvent | APIGatewayProxyEventV2 | ALBEv
329331

330332
if (eventType.isLambdaUrlEvent(event)) {
331333
const requestContext = event.requestContext;
334+
const path = requestContext.http.path;
332335
if (requestContext.domainName) {
333-
httpTags["http.url"] = `https://${requestContext.domainName}`;
336+
httpTags["http.url"] = `https://${requestContext.domainName}${path ?? ""}`;
334337
}
335-
httpTags["http.url_details.path"] = requestContext.http.path;
338+
httpTags["http.url_details.path"] = path;
336339
httpTags["http.method"] = requestContext.http.method;
337340
if (event.headers?.Referer) {
338341
httpTags["http.referer"] = event.headers.Referer;

0 commit comments

Comments
 (0)