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

Azure.monitor.opentelemetry.exporter replace pkg_resources with importlib.metadata #30018

Merged
merged 4 commits into from
Apr 27, 2023

Conversation

jenshnielsen
Copy link
Contributor

Description

Azure.monitor.opentelemetry.exporter is currently using pkg_resources to find the version of opentelemetry sdk.
Usage pkg_resources is discouraged and the same functionality is available in importlib.metadata in the std lib.

The main problem with pkg_resources is that import is very slow since it scans all installed packages at import. Opentelemetry it self dropped the usage of it in 1.17 this means that is a Azure exported telemetry config this package is now the only one that imports pkg_resources.

Since this functionality was added to the std lib in 3.8 we use the official backported package for 3.7. Note that opentelemetry already depends on this package in a similar way.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes. n/a
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes. (n/a)

@github-actions github-actions bot added Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor - Exporter Monitor OpenTelemetry Exporter labels Apr 21, 2023
@github-actions
Copy link

Thank you for your contribution @jenshnielsen! We will review the pull request and get back to you soon.

Copy link
Contributor

@basnijholt basnijholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks a lot!

Previously importing this was 30% of the total import time of a package I maintain.

@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

jenshnielsen and others added 3 commits April 25, 2023 11:57
Replace use of discuraged pkg_resources with importlib.metadata
falling back to backport package for python 3.7
@jenshnielsen jenshnielsen force-pushed the opentelemetry_drop_pkg_resources branch from 8037857 to 0ad89ea Compare April 25, 2023 09:57
@lzchen lzchen merged commit 1576321 into Azure:main Apr 27, 2023
@jenshnielsen jenshnielsen deleted the opentelemetry_drop_pkg_resources branch April 28, 2023 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor - Exporter Monitor OpenTelemetry Exporter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants