File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
opentelemetry-api/src/opentelemetry/util Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
22
22
([ #4634 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/4634 ) )
23
23
- semantic-conventions: Bump to 1.37.0
24
24
([ #4731 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/4731 ) )
25
+ - Performance: Cache ` importlib_metadata.entry_points `
26
+ ([ #4735 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/4735 ) )
25
27
26
28
## Version 1.36.0/0.57b0 (2025-07-29)
27
29
Original file line number Diff line number Diff line change 12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
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
16
19
# the supported versions at that time have the same API.
17
20
from importlib_metadata import ( # type: ignore
18
21
Distribution ,
19
22
EntryPoint ,
20
23
EntryPoints ,
21
24
PackageNotFoundError ,
22
25
distributions ,
23
- entry_points ,
24
26
requires ,
25
27
version ,
26
28
)
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
+
27
45
28
46
__all__ = [
29
47
"entry_points" ,
You can’t perform that action at this time.
0 commit comments