Open serkan-ozal opened 1 month ago
To get rid of the request library import delay, might switching to lower level one like urllib or urllib3 be an option?
Yeah, I think it would make sense to try prototyping one exporter using plain urllib3 instead of requests
Let me add that the current implementation is tied to requests so eventually another one should be added instead of changing it to avoid breaking backwards compatibility.
@xrmx Maybe we can implement OTLP JSON span exporter on top of urrlib3
from the beginning. So, in the Lambda layer side, we can use it by default, so we will be able to get rid of both requests
and opentelemetry.exporter.otlp.proto.common._internal
import delays. Does that make sense?
@xrmx Maybe we can implement OTLP JSON span exporter on top of
urrlib3
from the beginning. So, in the Lambda layer side, we can use it by default, so we will be able to get rid of bothrequests
andopentelemetry.exporter.otlp.proto.common._internal
import delays. Does that make sense?
I don't know, that would be something to bring to the weekly call and ask for feedback maybe?
Was choosing requests
over urllib
or urlib3
a conscious choice in opentelemetry? @xrmx @serkan-ozal
@bhaskarbanerjee replacing requests
with urlib3
helped me to save about 150
milliseconds in a Lambda function with 512 MB memory limit. It is just one of the a few optimizations that needs to be done for reducing coldstart delays in Lambda.
Anyway, implementing lightweight versions of trace and metrics OTLP exporters to be used only by otel_wrapper.py
in the opentelemetry-lambda
repo makes more sense to me now. So probably, I will send PR to that repo, not here.
Describe your environment
Environment:
AWS Lambda
Python version:Python 3.9
SDK version:1.26.0
API version:1.26.0
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.exporter.otlp.proto.http.trace_exporter.OTLPSpanExporter
is slow, because of therequests
andopentelemetry.exporter.otlp.proto.common._internal
imports as shown below.opentelemetry.exporter.otlp.proto.common._internal
, but wanted to ask what we can do to improve for therequests
module import latency.request
library import delay.request
library import delay, might switching to lower level one likeurllib
orurllib3
be an option?Here is the portion of the module import timings related to
opentelemetry.exporter.otlp.proto.http.trace_exporter.OTLPSpanExporter
module import in a Lambda function with 512 MB memory. As you can see thatopentelemetry.exporter.otlp.proto.http.trace_exporter.OTLPSpanExporter
module import took367 ms
requests
module import took236 ms
(64%
)opentelemetry.exporter.otlp.proto.common._internal
took110 ms
(30%
)Steps to Reproduce
PYTHONPROFILEIMPORTTIME
env var totrue
in theotel-instrument
bash script of the OTEL Python Lambda layeropentelemetry.exporter.otlp.proto.http.trace_exporter.OTLPSpanExporter
moduleExpected Result
-
Actual Result
-
Additional context
No response
Would you like to implement a fix?
None