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

Importing "from opencensus.ext.azure.log_exporter import AzureLogHandler" takes 0.6 -2.4 seconds #1176

Open
et-at-micro opened this issue Dec 17, 2022 · 2 comments
Labels
azure Microsoft Azure bug

Comments

@et-at-micro
Copy link

et-at-micro commented Dec 17, 2022

Describe your environment.
python 3.10.8
opencensus-ext-azure==1.1.7
mac Ventura or windows 11.
macbook pro 16 inch core i9
windows Intel 8700k

Steps to reproduce.
time python -c "from opencensus.ext.azure.log_exporter import AzureLogHandler"
vs
time python -c ""
What is the expected behavior?
Similar runtime.
What is the actual behavior?
time python -c "" # ~0.1-0.13 seconds
time python -c "from opencensus.ext.azure.log_exporter import AzureLogHandler" # ~0.7 - 2.6 seconds

Importing opencensus.ext.azure.log_exporter takes between 0.6 - 2.5 seconds to import.

Additional context.
This limits the ability to use opencensus.ext.azure in any cli application where startup times are crucial.
I tried lazy loading the module but that gives me errors.
Adding here profiling of import:
image

@lzchen
Copy link
Contributor

lzchen commented Jan 3, 2023

@et-at-micro

Thanks for doing this analysis. Curious would you be able to get the import time statistics for the trace and metrics exporters as well and compare them?

@lzchen lzchen added the azure Microsoft Azure label Jan 9, 2023
@et-at-micro
Copy link
Author

et-at-micro commented Jan 10, 2023

@lzchen

trace_exporter
metrics_exporter

Updates:
Just the import without python bootime etc we are looking at ~690-760ms for all the tools.
The biggest single impact is with the import to MSAL that imports http.server (python standard library) that takes ~300ms and opencensus.ext.azure.common.transport already explicitly imports requests (external http server) that takes ~100ms.
That alone can save 30% of total import time.
The second is opencensus.trace.status that makes up for another 30% of import time.
this import google rpc and pkg_resources.

I did not see any large differences in metrics, logs or traces in import time or the biggest time consumers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure Microsoft Azure bug
Projects
None yet
Development

No branches or pull requests

2 participants