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

Conversation

rypdal
Copy link
Contributor

@rypdal rypdal commented Sep 9, 2022

Changes

Added HTTP Server semantic conventions required tags to Activity created in OpenTelemetry.Instrumentation.AWSLambda.

rypdal added 13 commits August 12, 2022 14:18
- refactored internal Trace methods calls in order to access value returned by handler
- check header also in APIGatewayProxyRequest.Headers collection
- implemented setting of HTTP Server tags on Activity start
…tions-attributes

# Conflicts:
#	src/OpenTelemetry.Instrumentation.AWSLambda/AWSLambdaWrapper.cs
#	src/OpenTelemetry.Instrumentation.AWSLambda/Implementation/CommonExtensions.cs
#	src/OpenTelemetry.Instrumentation.AWSLambda/Implementation/HttpSemanticConventions.cs
…tions-attributes

# Conflicts:
#	src/OpenTelemetry.Instrumentation.AWSLambda/AWSLambdaWrapper.cs
…-forwarded-port" + adapted unit tests respectively
…tions-attributes

# Conflicts:
#	src/OpenTelemetry.Instrumentation.AWSLambda/AWSLambdaWrapper.cs
@rypdal rypdal requested a review from a team September 9, 2022 12:53
@github-actions github-actions bot requested a review from Oberon00 September 9, 2022 12:54
@codecov
Copy link

codecov bot commented Sep 9, 2022

Codecov Report

Merging #626 (b26223b) into main (59dbc5d) will increase coverage by 0.36%.
The diff coverage is 94.94%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #626      +/-   ##
==========================================
+ Coverage   77.22%   77.59%   +0.36%     
==========================================
  Files         173      175       +2     
  Lines        5160     5222      +62     
==========================================
+ Hits         3985     4052      +67     
+ Misses       1175     1170       -5     
Impacted Files Coverage Δ
...ntation.AWSLambda/Implementation/AWSLambdaUtils.cs 88.05% <80.00%> (+9.79%) ⬆️
...ation.AWSLambda/Implementation/CommonExtensions.cs 80.00% <80.00%> (ø)
...etry.Instrumentation.AWSLambda/AWSLambdaWrapper.cs 94.73% <96.55%> (+0.39%) ⬆️
...ion.AWSLambda/Implementation/AWSLambdaHttpUtils.cs 100.00% <100.00%> (ø)

@Oberon00
Copy link
Member

Oberon00 commented Sep 9, 2022

Hi, I would propose we merge this only after the first release is cut in #590.

@utpilla utpilla added the comp:instrumentation.awslambda Things related to OpenTelemetry.Instrumentation.AWSLambda label Sep 12, 2022
@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Sep 20, 2022
@rypdal
Copy link
Contributor Author

rypdal commented Sep 20, 2022

This PR was waiting for the next -beta release. The release was published and PR can be further reviewed and merged.

…tions-attributes

# Conflicts:
#	src/OpenTelemetry.Instrumentation.AWSLambda/AWSLambdaWrapper.cs
#	src/OpenTelemetry.Instrumentation.AWSLambda/Implementation/AWSLambdaUtils.cs
@github-actions github-actions bot removed the Stale label Sep 21, 2022
Applied review

Co-authored-by: Christian Neumüller <christian+github@neumueller.me>
@rypdal
Copy link
Contributor Author

rypdal commented Sep 29, 2022

I think this now looks mostly done, only a few nitpicks left. 👍 Thank you for addressing my comments!

@Oberon00, thank you for the review !

Copy link
Member

@Oberon00 Oberon00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need make sure the URL-encoding of the query string parts is correct, see
#626 (comment)

rypdal and others added 3 commits September 29, 2022 14:26
…LambdaHttpUtils.cs

Co-authored-by: Christian Neumüller <christian+github@neumueller.me>
- added url encoding of http parameters names and values
- changed path source for v1 http trigger (REST) in order to include stage
@rypdal
Copy link
Contributor Author

rypdal commented Oct 3, 2022

Hi, I would propose we merge this only after the first release is cut in #590.

Hi @utpilla , the corresponding release already happened and this PR can be merged. The PR requires one more approval.

@utpilla utpilla changed the title Issue/aws lambda http server semantic conventions attributes [Instrumentation.AWSLambda] Issue/aws lambda http server semantic conventions attributes Oct 3, 2022
Copy link
Contributor

@utpilla utpilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rypdal Update the CHANGELOG.

@rypdal
Copy link
Contributor Author

rypdal commented Oct 4, 2022

@rypdal Update the CHANGELOG.

@utpilla - done. Thanks !

rypdal added 2 commits October 4, 2022 16:13
- adapted setting of http.target logic: it shouldn't be set if neither path nor query string is provided
- added unit tests for check last header value
- fixed CHANGELOG markup
@rypdal
Copy link
Contributor Author

rypdal commented Oct 4, 2022

I made small code adaptation to be aligned with the AWS doc (see request examples https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html):

  • use the last instead of the first value of multi-value headers (this can be seen from the example)
  • added respective unit tests
  • made logic for setting http.target more precise to exclude some edge case: this property shouldn't be set if neither path nor query string is provided

These changes shouldn't be obstacles for merge.

@Oberon00
Copy link
Member

Oberon00 commented Oct 4, 2022

this property shouldn't be set if neither path nor query string is provided

Is this possible? I don't think that would be a HTTP request then. Maybe we should fall back to / or empty string in this case?

@Oberon00
Copy link
Member

Oberon00 commented Oct 4, 2022

I think I would prefer always treating Path as if it was empty if it is actually null. But do not add extra code to try to get something sensible in these situations; just ensure we do not crash. Garbage-in/garbage-out applies here. (BTW: Before the next release we should ensure we catch any errors that happen before the traced handler is called and call it without tracing in the worst case; the code is now complex enough for a good chance of bugs)

@rypdal
Copy link
Contributor Author

rypdal commented Oct 5, 2022

I think I would prefer always treating Path as if it was empty if it is actually null. But do not add extra code to try to get something sensible in these situations; just ensure we do not crash. Garbage-in/garbage-out applies here. (BTW: Before the next release we should ensure we catch any errors that happen before the traced handler is called and call it without tracing in the worst case; the code is now complex enough for a good chance of bugs)

this property shouldn't be set if neither path nor query string is provided

Is this possible? I don't think that would be a HTTP request then. Maybe we should fall back to / or empty string in this case?

@Oberon00 : I rolled back to the previous code and updated unit test. So, even if neither path nor query string is set the http.target is still set to an empty string.

@rypdal
Copy link
Contributor Author

rypdal commented Oct 5, 2022

Seems build fails because of failing test not related to changes from this PR:

Failed OpenTelemetry.Instrumentation.Wcf.Tests.TelemetryClientMessageInspectorTests.OutgoingRequestInstrumentationTest(instrument: True, filter: False, suppressDownstreamInstrumentation: True, includeVersion: True, enrich: False, enrichmentException: False, emptyOrNullAction: False) [1 ms]
Error Message:
System.ObjectDisposedException : Cannot access a disposed object.

Details can be found here: https://github.com/open-telemetry/opentelemetry-dotnet-contrib/actions/runs/3188299150/jobs/5200797125

open-telemetry#583: applied re-phrasing

Co-authored-by: Christian Neumüller <christian+github@neumueller.me>
@Oberon00
Copy link
Member

Oberon00 commented Oct 5, 2022

I think this PR can be merged now. (The build failure was indeed unrelated, it became green after changing the totally unrelated CHANGELOG)
CC @utpilla

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:instrumentation.awslambda Things related to OpenTelemetry.Instrumentation.AWSLambda
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants