- Notifications
You must be signed in to change notification settings - Fork 809
Add support for ALB events in opentelemetry-instrumentation-aws-lambda #2585
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
base: main
Are you sure you want to change the base?
Add support for ALB events in opentelemetry-instrumentation-aws-lambda #2585
Conversation
...ion/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py Outdated Show resolved Hide resolved
| @jbfenton need a changelog entry |
...elemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py Outdated Show resolved Hide resolved
2d0e287 to 9ee67ca Compare | if not hasattr(tracer_provider, "force_flush"): | ||
| tracer_provider.force_flush = provider_warning( | ||
| provider_type="TracerProvider" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting all this work and testing in!
I don't quite understand the functionality/conveniences the new FlushableTracerProvider and FlushableMeterProvider provide, since the SDK's versions have force_flush implemented (here and here). If a user or vendor implemented their own by extending the API, would the not hasattr check and set be enough? Or, why not update the API instead so other instrumentors could use this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally the Flushable Providers don't serve any purpose other than fixing up some type-hinting issues.
I'll have a look back through and see if it can be optimised.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a look at this today, it's great to have the tests with proper mock responses but the amount of code that has been added was intimidating 😅
Would it possible to first add the tests and add whatever minimal change is eventually needed to have them pass and do the refactoring later?
Thanks for taking a look! I'm happy to split this across a couple of PRs, I'll transition this PR back to draft, and spin up a new PR to introduce tests first. |
Description
The current
opentelemetry-instrumentation-aws-lambdamodule only supports conventional API Gateway events which typically contain aheadersfield that the trace context can be extracted from.ALB events will only contain a
headersfield whenMulti value headersis disabled for the ALB in question. Otherwise the necessary headers will be found under the 'multiValueHeaders` field:ELB: Lambda functions as targets
As a part of implementing this change, types + interfaces of the instrumentation have been hardened so that we avoid passing
Optionalparameters down the call chain wherever it is practical.Handlers for processing types of events have also been placed in wrappers to make it a little easier to identify where we are pulling the trace context from, and where/why a given set of span attributes is being extracted + applied.
The hope is that in the future if someone wanted to add an additional span attribute for an API Gateway Proxy they could simply add it to
APIGatewayProxyWrapper.set_pre_execution_span_attributeswithout risk of breaking any of the other event handlers.This change should also resolve: #2511
Type of change
Please delete options that are not relevant.
event_context_extractorthat has changed.How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.