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
2222 ([ #4634 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/4634 ) )
2323- semantic-conventions: Bump to 1.37.0
2424 ([ #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 ) )
2527
2628## Version 1.36.0/0.57b0 (2025-07-29)
2729
Original file line number Diff line number Diff line change 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.
1720from 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" ,
You can’t perform that action at this time.
0 commit comments