Skip to content

Commit

Permalink
update AWS Lambda tests to use v1.10.1 semantic convention
Browse files Browse the repository at this point in the history
  • Loading branch information
ppittle committed Dec 6, 2024
1 parent f5cbe31 commit 853462a
Showing 1 changed file with 47 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ namespace OpenTelemetry.Instrumentation.AWSLambda.Tests.Implementation;
[Collection("TracerProviderDependent")]
public class AWSLambdaHttpUtilsTests
{
private static class ExpectedSemanticConventions
{
public const string AttributeHttpScheme = "url.scheme";
public const string AttributeHttpTarget = "http.target";
public const string AttributeNetHostName = "server.address";
public const string AttributeNetHostPort = "server.port";
public const string AttributeHttpMethod = "http.request.method";
public const string AttributeHttpStatusCode = "http.response.status_code";
}

[Fact]
public void GetHttpTags_APIGatewayProxyRequest_ReturnsCorrectTags()
{
Expand Down Expand Up @@ -40,11 +50,11 @@ public void GetHttpTags_APIGatewayProxyRequest_ReturnsCorrectTags()

var expectedTags = new Dictionary<string, object>
{
{ "http.scheme", "https" },
{ "http.target", "/path/test?q1=value1" },
{ "net.host.name", "localhost" },
{ "net.host.port", 1234 },
{ "http.method", "GET" },
{ ExpectedSemanticConventions.AttributeHttpScheme, "https" },
{ ExpectedSemanticConventions.AttributeHttpTarget, "/path/test?q1=value1" },
{ ExpectedSemanticConventions.AttributeNetHostName, "localhost" },
{ ExpectedSemanticConventions.AttributeNetHostPort, 1234 },
{ ExpectedSemanticConventions.AttributeHttpMethod, "GET" },
};

AssertTags(expectedTags, actualTags);
Expand Down Expand Up @@ -72,11 +82,11 @@ public void GetHttpTags_ApplicationLoadBalancerRequest_ReturnsCorrectTags()

var expectedTags = new Dictionary<string, object>
{
{ "http.scheme", "https" },
{ "http.target", "/path/test?q1=value1" },
{ "net.host.name", "localhost" },
{ "net.host.port", 1234 },
{ "http.method", "GET" },
{ ExpectedSemanticConventions.AttributeHttpScheme, "https" },
{ ExpectedSemanticConventions.AttributeHttpTarget, "/path/test?q1=value1" },
{ ExpectedSemanticConventions.AttributeNetHostName, "localhost" },
{ ExpectedSemanticConventions.AttributeNetHostPort, 1234 },
{ ExpectedSemanticConventions.AttributeHttpMethod, "GET" },
};

AssertTags(expectedTags, actualTags);
Expand Down Expand Up @@ -106,11 +116,11 @@ public void GetHttpTags_ApplicationLoadBalancerRequestWithMultiValue_ReturnsCorr

var expectedTags = new Dictionary<string, object>
{
{ "http.scheme", "https" },
{ "http.target", "/path/test?q1=value1" },
{ "net.host.name", "localhost" },
{ "net.host.port", 1234 },
{ "http.method", "GET" },
{ ExpectedSemanticConventions.AttributeHttpScheme, "https" },
{ ExpectedSemanticConventions.AttributeHttpTarget, "/path/test?q1=value1" },
{ ExpectedSemanticConventions.AttributeNetHostName, "localhost" },
{ ExpectedSemanticConventions.AttributeNetHostPort, 1234 },
{ ExpectedSemanticConventions.AttributeHttpMethod, "GET" },
};

AssertTags(expectedTags, actualTags);
Expand All @@ -132,10 +142,10 @@ public void GetHttpTags_ApplicationLoadBalancerRequestWithMultiValueHeader_UsesL

var expectedTags = new Dictionary<string, object>
{
{ "http.target", string.Empty },
{ "http.scheme", "http" },
{ "net.host.name", "myhost" },
{ "net.host.port", 432 },
{ ExpectedSemanticConventions.AttributeHttpTarget, string.Empty },
{ ExpectedSemanticConventions.AttributeHttpScheme, "http" },
{ ExpectedSemanticConventions.AttributeNetHostName, "myhost" },
{ ExpectedSemanticConventions.AttributeNetHostPort, 432 },
};

AssertTags(expectedTags, actualTags);
Expand All @@ -160,7 +170,7 @@ public void SetHttpTagsFromResult_ApplicationLoadBalancerResponse_SetsCorrectTag

var expectedTags = new Dictionary<string, object>
{
{ "http.status_code", 200 },
{ ExpectedSemanticConventions.AttributeHttpStatusCode, 200 },
};

var actualTags = activity?.TagObjects
Expand Down Expand Up @@ -237,8 +247,8 @@ public void GetHttpTags_APIGatewayProxyRequestWithEmptyContext_ReturnsTagsFromRe

var expectedTags = new Dictionary<string, object>
{
{ "http.method", "POST" },
{ "http.target", "/path/test?q1=value1" },
{ ExpectedSemanticConventions.AttributeHttpMethod, "POST" },
{ ExpectedSemanticConventions.AttributeHttpTarget, "/path/test?q1=value1" },
};

AssertTags(expectedTags, actualTags);
Expand All @@ -260,10 +270,10 @@ public void GetHttpTags_APIGatewayProxyRequestWithMultiValueHeader_UsesLastValue

var expectedTags = new Dictionary<string, object>
{
{ "http.target", string.Empty },
{ "http.scheme", "http" },
{ "net.host.name", "myhost" },
{ "net.host.port", 432 },
{ ExpectedSemanticConventions.AttributeHttpTarget, string.Empty },
{ ExpectedSemanticConventions.AttributeHttpScheme, "http" },
{ ExpectedSemanticConventions.AttributeNetHostName, "myhost" },
{ ExpectedSemanticConventions.AttributeNetHostPort, 432 },
};

AssertTags(expectedTags, actualTags);
Expand Down Expand Up @@ -294,11 +304,11 @@ public void GetHttpTags_APIGatewayHttpApiV2ProxyRequest_ReturnsCorrectTags()

var expectedTags = new Dictionary<string, object>
{
{ "http.scheme", "https" },
{ "http.target", "/path/test?q1=value1" },
{ "net.host.name", "localhost" },
{ "net.host.port", 1234 },
{ "http.method", "GET" },
{ ExpectedSemanticConventions.AttributeHttpScheme, "https" },
{ ExpectedSemanticConventions.AttributeHttpTarget, "/path/test?q1=value1" },
{ ExpectedSemanticConventions.AttributeNetHostName, "localhost" },
{ ExpectedSemanticConventions.AttributeNetHostPort, 1234 },
{ ExpectedSemanticConventions.AttributeHttpMethod, "GET" },
};

AssertTags(expectedTags, actualTags);
Expand All @@ -320,10 +330,10 @@ public void GetHttpTags_APIGatewayHttpApiV2ProxyRequestWithMultiValueHeader_Uses

var expectedTags = new Dictionary<string, object>
{
{ "http.target", string.Empty },
{ "http.scheme", "http" },
{ "net.host.name", "myhost" },
{ "net.host.port", 432 },
{ ExpectedSemanticConventions.AttributeHttpTarget, string.Empty },
{ ExpectedSemanticConventions.AttributeHttpScheme, "http" },
{ ExpectedSemanticConventions.AttributeNetHostName, "myhost" },
{ ExpectedSemanticConventions.AttributeNetHostPort, 432 },
};

AssertTags(expectedTags, actualTags);
Expand All @@ -348,7 +358,7 @@ public void SetHttpTagsFromResult_APIGatewayProxyResponse_SetsCorrectTags()

var expectedTags = new Dictionary<string, object>
{
{ "http.status_code", 200 },
{ ExpectedSemanticConventions.AttributeHttpStatusCode, 200 },
};

Assert.NotNull(activity);
Expand Down Expand Up @@ -377,7 +387,7 @@ public void SetHttpTagsFromResult_APIGatewayHttpApiV2ProxyResponse_SetsCorrectTa

var expectedTags = new Dictionary<string, object>
{
{ "http.status_code", 200 },
{ ExpectedSemanticConventions.AttributeHttpStatusCode, 200 },
};

var actualTags = activity?.TagObjects
Expand Down

0 comments on commit 853462a

Please sign in to comment.