diff --git a/src/OpenTelemetry.Instrumentation.AWSLambda/Implementation/AWSLambdaHttpUtils.cs b/src/OpenTelemetry.Instrumentation.AWSLambda/Implementation/AWSLambdaHttpUtils.cs index 60541fd64d..25adefc903 100644 --- a/src/OpenTelemetry.Instrumentation.AWSLambda/Implementation/AWSLambdaHttpUtils.cs +++ b/src/OpenTelemetry.Instrumentation.AWSLambda/Implementation/AWSLambdaHttpUtils.cs @@ -44,32 +44,14 @@ internal static IEnumerable> GetHttpTags(TI { case APIGatewayProxyRequest request: httpScheme = AWSLambdaUtils.GetHeaderValues(request, HeaderXForwardedProto)?.LastOrDefault(); - var queryString = GetQueryString(request); - if (request.RequestContext?.Path != null) - { - httpTarget = string.Concat(request.RequestContext.Path, queryString); - } - else if (!string.IsNullOrEmpty(queryString)) - { - httpTarget = queryString; - } - + httpTarget = string.Concat(request.RequestContext?.Path ?? string.Empty, GetQueryString(request)); httpMethod = request.HttpMethod; var hostHeader = AWSLambdaUtils.GetHeaderValues(request, HeaderHost)?.LastOrDefault(); (hostName, hostPort) = GetHostAndPort(httpScheme, hostHeader); break; case APIGatewayHttpApiV2ProxyRequest requestV2: httpScheme = AWSLambdaUtils.GetHeaderValues(requestV2, HeaderXForwardedProto)?.LastOrDefault(); - var queryStringV2 = GetQueryString(requestV2); - if (requestV2.RawPath != null) - { - httpTarget = string.Concat(requestV2.RawPath, queryStringV2); - } - else if (!string.IsNullOrEmpty(queryStringV2)) - { - httpTarget = queryStringV2; - } - + httpTarget = string.Concat(requestV2.RawPath ?? string.Empty, GetQueryString(requestV2)); httpMethod = requestV2.RequestContext?.Http?.Method; var hostHeaderV2 = AWSLambdaUtils.GetHeaderValues(requestV2, HeaderHost)?.LastOrDefault(); (hostName, hostPort) = GetHostAndPort(httpScheme, hostHeaderV2); diff --git a/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/Implementation/AWSLambdaHttpUtilsTests.cs b/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/Implementation/AWSLambdaHttpUtilsTests.cs index 46edfbefd1..a5ecf93424 100644 --- a/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/Implementation/AWSLambdaHttpUtilsTests.cs +++ b/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/Implementation/AWSLambdaHttpUtilsTests.cs @@ -78,6 +78,7 @@ public void GetHttpTags_APIGatewayProxyRequestWithMultiValueHeader_UsesLastValue var expectedTags = new Dictionary { + { "http.target", string.Empty }, { "http.scheme", "http" }, { "net.host.name", "myhost" }, { "net.host.port", 432 }, @@ -137,6 +138,7 @@ public void GetHttpTags_APIGatewayHttpApiV2ProxyRequestWithMultiValueHeader_Uses var expectedTags = new Dictionary { + { "http.target", string.Empty }, { "http.scheme", "http" }, { "net.host.name", "myhost" }, { "net.host.port", 432 },