Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#4634](https://github.com/open-telemetry/opentelemetry-python/pull/4634))
- semantic-conventions: Bump to 1.37.0
([#4731](https://github.com/open-telemetry/opentelemetry-python/pull/4731))
- Performance: Cache `importlib_metadata.entry_points`
([#4735](https://github.com/open-telemetry/opentelemetry-python/pull/4735))

## Version 1.36.0/0.57b0 (2025-07-29)

Expand Down
22 changes: 20 additions & 2 deletions opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,36 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# FIXME: Use importlib.metadata when support for 3.11 is dropped if the rest of
from functools import cache

# FIXME: Use importlib.metadata (not importlib_metadata)
# when support for 3.11 is dropped if the rest of
# the supported versions at that time have the same API.
from importlib_metadata import ( # type: ignore
Distribution,
EntryPoint,
EntryPoints,
PackageNotFoundError,
distributions,
entry_points,
requires,
version,
)
from importlib_metadata import (
entry_points as original_entry_points,
)


@cache
def _original_entry_points_cached():
return original_entry_points()


def entry_points(**params):
"""Replacement for importlib_metadata.entry_points that caches getting all the entry points.

That part can be very slow, and OTel uses this function many times."""
return _original_entry_points_cached().select(**params)


__all__ = [
"entry_points",
Expand Down
Loading