File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
opentelemetry-api/src/opentelemetry/util Expand file tree Collapse file tree 1 file changed +18
-3
lines changed 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
16- # the supported versions at that time have the same API.
15+ from functools import lru_cache
16+
1717from importlib_metadata import ( # type: ignore
1818 Distribution ,
1919 EntryPoint ,
2020 EntryPoints ,
2121 PackageNotFoundError ,
2222 distributions ,
23- entry_points ,
2423 requires ,
2524 version ,
2625)
26+ from importlib_metadata import (
27+ entry_points as original_entry_points ,
28+ )
29+
30+
31+ @lru_cache ()
32+ def _original_entry_points_cached ():
33+ return original_entry_points ()
34+
35+
36+ def entry_points (** params ):
37+ """Replacement for importlib_metadata.entry_points that caches getting all the entry points.
38+
39+ That part can be very slow, and OTel uses this function many times."""
40+ return _original_entry_points_cached ().select (** params )
41+
2742
2843__all__ = [
2944 "entry_points" ,
You can’t perform that action at this time.
0 commit comments