Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Instrumentation.AWSLambda] Issue/aws lambda http server semantic conventions attributes #626

Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
63a2a72
#583: HTTP Server semantic conventions for AWS Lambdas
rypdal Aug 12, 2022
1ea5224
#583: unit test for getting tags from AWS API Gateway request + comme…
rypdal Aug 12, 2022
f5abd7f
Merge branch 'main' into issue/AWS-Lambda-HTTP-Server-semantic-conven…
rypdal Sep 2, 2022
1aed8f3
#583: set http.status_code activity tag as string + unit tests
rypdal Sep 2, 2022
04f41c8
#583: added more unit tests
rypdal Sep 5, 2022
f294e75
Merge branch 'main' into issue/AWS-Lambda-HTTP-Server-semantic-conven…
rypdal Sep 5, 2022
1084c51
#583: port is taken from host after ":" and not from "x-forwarded-por…
rypdal Sep 5, 2022
ebf2c7e
#583: unit tests for common extensions
rypdal Sep 6, 2022
3761a23
#583: additional null-check
rypdal Sep 6, 2022
fde0c99
#583: use original casing for header names
rypdal Sep 6, 2022
8f5a6b5
Merge branch 'main' into issue/AWS-Lambda-HTTP-Server-semantic-conven…
rypdal Sep 8, 2022
a3a6420
#583: added default ports for setting net.host.port
rypdal Sep 8, 2022
5f86d10
Merge branch 'main' into issue/AWS-Lambda-HTTP-Server-semantic-conven…
rypdal Sep 9, 2022
b15b36e
Merge branch 'main' into issue/AWS-Lambda-HTTP-Server-semantic-conven…
rypdal Sep 12, 2022
22549ca
#583: port tag must be integer + additional unit tests
rypdal Sep 12, 2022
0047c5f
Merge branch 'main' into issue/AWS-Lambda-HTTP-Server-semantic-conven…
rypdal Sep 20, 2022
bf07052
Update src/OpenTelemetry.Instrumentation.AWSLambda/AWSLambdaWrapper.cs
rypdal Sep 23, 2022
baa673f
Update src/OpenTelemetry.Instrumentation.AWSLambda/Implementation/Com…
rypdal Sep 23, 2022
c87c039
#583: review suggestion
rypdal Sep 23, 2022
02c12f3
Merge branch 'issue/AWS-Lambda-HTTP-Server-semantic-conventions-attri…
rypdal Sep 23, 2022
937757b
#583: iterate dict only once when searching for header
rypdal Sep 23, 2022
2bd7cdb
Merge branch 'main' into issue/AWS-Lambda-HTTP-Server-semantic-conven…
rypdal Sep 23, 2022
5e461ba
#583: removed case-insensitive header search as only lower-case is ex…
rypdal Sep 23, 2022
f7037b4
#583: ignore header names case + added query string to http.target at…
rypdal Sep 26, 2022
184df8c
#583: aligned file names in it's headers
rypdal Sep 26, 2022
212b102
Merge branch 'main' into issue/AWS-Lambda-HTTP-Server-semantic-conven…
rypdal Sep 27, 2022
5c9c33e
#583: set http.status_code tag as integer
rypdal Sep 27, 2022
3c6f4b2
#583: extracting common methods for getting headers
rypdal Sep 27, 2022
ecd07a8
#583: renamed class according to project's convention
rypdal Sep 27, 2022
440c737
#583: simplified method
rypdal Sep 27, 2022
966e235
#583: changed HTTP query string construction for both versions of AWS…
rypdal Sep 28, 2022
89fcb80
Update src/OpenTelemetry.Instrumentation.AWSLambda/Implementation/Com…
rypdal Sep 28, 2022
26eb882
Update src/OpenTelemetry.Instrumentation.AWSLambda/Implementation/AWS…
rypdal Sep 28, 2022
74fbe8b
Update src/OpenTelemetry.Instrumentation.AWSLambda/Implementation/AWS…
rypdal Sep 29, 2022
a6f63c3
#583: additional review suggestions and code improvements
rypdal Sep 29, 2022
1d0db13
Merge branch 'issue/AWS-Lambda-HTTP-Server-semantic-conventions-attri…
rypdal Sep 29, 2022
c4b57ff
#583: optimized GetQueryString method
rypdal Sep 29, 2022
f83857d
Merge branch 'main' into issue/AWS-Lambda-HTTP-Server-semantic-conven…
rypdal Sep 29, 2022
0d51176
#583: removed unused using
rypdal Sep 29, 2022
632f065
Update src/OpenTelemetry.Instrumentation.AWSLambda/Implementation/AWS…
rypdal Sep 29, 2022
6823817
#583:
rypdal Sep 29, 2022
9ac42f5
#583: added test for space encoding
rypdal Sep 29, 2022
068123b
Merge branch 'main' into issue/AWS-Lambda-HTTP-Server-semantic-conven…
rypdal Oct 3, 2022
28bd1e6
#583: CHANGELOG update
rypdal Oct 4, 2022
82396c5
#583: use the last instead of the first value of multi-value headers
rypdal Oct 4, 2022
9d6c173
#583:
rypdal Oct 4, 2022
60561b7
Merge branch 'main' into issue/AWS-Lambda-HTTP-Server-semantic-conven…
rypdal Oct 5, 2022
4bd334b
#583: code rollback: fallback to empty string if path is not set and …
rypdal Oct 5, 2022
b26223b
Update src/OpenTelemetry.Instrumentation.AWSLambda/CHANGELOG.md
rypdal Oct 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/OpenTelemetry.Instrumentation.AWSLambda/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Implemented minimal HTTP Server semantic conventions attributes set
rypdal marked this conversation as resolved.
Show resolved Hide resolved
([#626](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/626))

## 1.1.0-beta.2

Release PR: [#590](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/590)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ internal static IEnumerable<KeyValuePair<string, object>> GetHttpTags<TInput>(TI
switch (input)
{
case APIGatewayProxyRequest request:
httpScheme = AWSLambdaUtils.GetHeaderValues(request, HeaderXForwardedProto)?.FirstOrDefault();
httpScheme = AWSLambdaUtils.GetHeaderValues(request, HeaderXForwardedProto)?.LastOrDefault();
httpTarget = string.Concat(request.RequestContext?.Path ?? string.Empty, GetQueryString(request));
httpMethod = request.HttpMethod;
var hostHeader = AWSLambdaUtils.GetHeaderValues(request, HeaderHost)?.FirstOrDefault();
var hostHeader = AWSLambdaUtils.GetHeaderValues(request, HeaderHost)?.LastOrDefault();
(hostName, hostPort) = GetHostAndPort(httpScheme, hostHeader);
break;
case APIGatewayHttpApiV2ProxyRequest requestV2:
httpScheme = AWSLambdaUtils.GetHeaderValues(requestV2, HeaderXForwardedProto)?.FirstOrDefault();
httpScheme = AWSLambdaUtils.GetHeaderValues(requestV2, HeaderXForwardedProto)?.LastOrDefault();
httpTarget = string.Concat(requestV2.RawPath ?? string.Empty, GetQueryString(requestV2));
httpMethod = requestV2.RequestContext?.Http?.Method;
var hostHeaderV2 = AWSLambdaUtils.GetHeaderValues(requestV2, HeaderHost)?.FirstOrDefault();
var hostHeaderV2 = AWSLambdaUtils.GetHeaderValues(requestV2, HeaderHost)?.LastOrDefault();
(hostName, hostPort) = GetHostAndPort(httpScheme, hostHeaderV2);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,31 @@ public void GetHttpTags_APIGatewayProxyRequest_ReturnsCorrectTags()
AssertTags(expectedTags, actualTags);
}

[Fact]
public void GetHttpTags_APIGatewayProxyRequestWithMultiValueHeader_UsesLastValue()
{
var request = new APIGatewayProxyRequest
{
MultiValueHeaders = new Dictionary<string, IList<string>>
{
{ "X-Forwarded-Proto", new List<string> { "https", "http" } },
{ "Host", new List<string> { "localhost:1234", "myhost:432" } },
},
};

var actualTags = AWSLambdaHttpUtils.GetHttpTags(request);

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

AssertTags(expectedTags, actualTags);
}

[Fact]
public void GetHttpTags_APIGatewayHttpApiV2ProxyRequest_ReturnsCorrectTags()
{
Expand Down Expand Up @@ -97,6 +122,31 @@ public void GetHttpTags_APIGatewayHttpApiV2ProxyRequest_ReturnsCorrectTags()
AssertTags(expectedTags, actualTags);
}

[Fact]
public void GetHttpTags_APIGatewayHttpApiV2ProxyRequestWithMultiValueHeader_UsesLastValue()
{
var request = new APIGatewayHttpApiV2ProxyRequest
{
Headers = new Dictionary<string, string>
{
{ "X-Forwarded-Proto", "https,http" },
{ "Host", "localhost:1234,myhost:432" },
},
};

var actualTags = AWSLambdaHttpUtils.GetHttpTags(request);

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

AssertTags(expectedTags, actualTags);
}

[Fact]
public void SetHttpTagsFromResult_APIGatewayProxyResponse_SetsCorrectTags()
{
Expand Down