-
Notifications
You must be signed in to change notification settings - Fork 232
feat: add support for running on AWS Lambda managed instance types #2083
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?
Conversation
|
Hi @herin049, For the Python SDK related changes, as far as I understood from your explanations, Because otherwise (if |
|
Hi @serkan-ozal, thanks for the review. Yes, your understanding is correct. To reiterate, here is what I assume happens internally for AWS Lambda managed instances:
I can't find any documentation on this except with the docs stating that managed lambda instances can serve many requests concurrently, and the only way to do this while achieving true parallelism with Python is to use multiple processes. Regardless, this change will ALWAYS be safe to make because even for standard lambda instances, the behavior will be identical. That is, running |
|
Yes, I know that using a wrapper handler which delegates to the user handler is a very common approach. But while asking to verify this behavioral change with the However, even though In addition to the points above, for Python, instead of wrapper handler, one other approach would be using |
|
Thanks @serkan-ozal I see where you are coming from now. To limit the scope of these changes I've just focused on the collector level changes and adding support for Python for now. If you'd like, I can create an issue for verifying/making changes for all of the supported lambda runtime for Lambda managed instances. I am not as familiar with how auto instrumentation works for the other runtimes, but I can certainly look into this more and make any required changes based on my findings in order to support managed instances. In either case, the collector changes I have made in this PR will not change even if there are substantial changes to the auto instrumentation logic in some runtimes. With regard to your concern with instrumenting the original parent process, I don't think this is a concern. I have not observed any irregular spans being reported even when enabling all of the auto instrumentation libraries. From what I have found so far, it seems like the auto instrumentation wrapper command is not working properly for the worker Python processes because somehow The reason I made the changes to the wrapper script the way I did is because: they are relatively minimal and the changes are backwards compatible, ensuring that the behavior is the same as the previous wrapper script. |
|
@herin049 I think it is better to limit the scope of this PR to only changes related to the collector. For the SDK related changes, first, I would like to understand the behavior for the main process and spawned processes (I will be looking into it too) when AWS Lambda managed instance is used. So, my take is please create issue(s) for the SDK related changes and remove the Python related changes from this PR. |
Sounds good to me @serkan-ozal. I have reverted the Python SDK related changes in this PR, I can work on a follow-up PR to update all of the SDKs where necessary to support managed instance types, and do some additional research myself. |
Yes I agree! |
2b22ef9 to
114e673
Compare
Adds support for running on AWS Lambda managed instances.
Lambda managed instances differ from standard lambda functions in several areas, but the differences most relevant for the OpenTelemetry collector layer are:
Invokeevent type.platform.runtimeDoneeventsdecoupleprocessor)For more information see: https://docs.aws.amazon.com/lambda/latest/dg/lambda-managed-instances.html
In order to accommodate the changes above, the following changes have been made to the layer if the extension determines the initialization type is
lambda-managed-instancesusing theAWS_LAMBDA_INITIALIZATION_TYPEenvironment variable:Invokeevent type, and the extension no longer subscribes to the telemetry API to listen for theplatform.runtimeDoneevent if the initialization type islambda-managed-instancesdecoupleprocessor is no longer added to any pipelines.FunctionInvoked()andFunctionFinished()lifecycle methods are no longer invoked for lifecycle listeners.I have added relevant unit tests and have manually verified the implementation using the following repo: https://github.com/herin049/aws-lambda-managed which configures the layer to export signals to Grafana cloud.