Skip to content

Commit 0fcdd7b

Browse files
authored
Merge branch 'main' into add_cred_envvar
2 parents 5336c95 + c71c4a4 commit 0fcdd7b

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ inject a `requests.Session` or `grpc.ChannelCredentials` object into OTLP export
2424
([#4634](https://github.com/open-telemetry/opentelemetry-python/pull/4634))
2525
- semantic-conventions: Bump to 1.37.0
2626
([#4731](https://github.com/open-telemetry/opentelemetry-python/pull/4731))
27+
- Performance: Cache `importlib_metadata.entry_points`
28+
([#4735](https://github.com/open-telemetry/opentelemetry-python/pull/4735))
2729

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

opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,36 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# FIXME: Use importlib.metadata when support for 3.11 is dropped if the rest of
15+
from functools import cache
16+
17+
# FIXME: Use importlib.metadata (not importlib_metadata)
18+
# when support for 3.11 is dropped if the rest of
1619
# the supported versions at that time have the same API.
1720
from importlib_metadata import ( # type: ignore
1821
Distribution,
1922
EntryPoint,
2023
EntryPoints,
2124
PackageNotFoundError,
2225
distributions,
23-
entry_points,
2426
requires,
2527
version,
2628
)
29+
from importlib_metadata import (
30+
entry_points as original_entry_points,
31+
)
32+
33+
34+
@cache
35+
def _original_entry_points_cached():
36+
return original_entry_points()
37+
38+
39+
def entry_points(**params):
40+
"""Replacement for importlib_metadata.entry_points that caches getting all the entry points.
41+
42+
That part can be very slow, and OTel uses this function many times."""
43+
return _original_entry_points_cached().select(**params)
44+
2745

2846
__all__ = [
2947
"entry_points",

0 commit comments

Comments
 (0)