Open serkan-ozal opened 2 weeks ago
@serkan-ozal What do you think of reconsider things after https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2181 ?
Hi @xrmx, Yes, that PR makes sense. Of course it is better if we could switch from pkg_resources
. I have verified that importing importlib.metadata
has negligible effect on Lambda coldstart.
Looking forward to get it approved, merged and released.
Describe your environment
Environment:
AWS Lambda
Python version:Python 3.9
Package version:0.47b0
What happened?
Initialization of the OTEL Python Lambda layer takes significant amount of time in the AWS Lambda environment because of module imports. When I have analyzed import timings, I have noticed that importing
opentelemetry.instrumentation.aws_lambda
is slow, because ofopentelemetry.instrumentation.instrumentor
>opentelemetry.instrumentation.dependencies
>pkg_resources
imports as shown below.Can we make importing
opentelemetry.instrumentation.dependencies
in theinstrumentor.py
lazy and optional (ignore whenskip_dep_check
arg isTrue
) here: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/98958b6f1ef09d332e13ea1d7bc308f8e9edd351/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py#L84 So we can configure/optimize it in the AWS Lambda Python layer side.Portion of the module import timings related to
opentelemetry.instrumentation.aws_lambda
module import in a Lambda function with512 MB
memory.Steps to Reproduce
PYTHONPROFILEIMPORTTIME
env var totrue
in theotel-instrument
bash scriptopentelemetry.instrumentation.aws_lambda
moduleExpected Result
-
Actual Result
-
Additional context
No response
Would you like to implement a fix?
None