File tree Expand file tree Collapse file tree 1 file changed +10
-14
lines changed
opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation Expand file tree Collapse file tree 1 file changed +10
-14
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+ from functools import cached_property
1516from logging import getLogger
1617from os import environ
1718
3536
3637
3738class _EntryPointDistFinder :
38- def __int__ (self ):
39- self ._mapping = None
39+ @cached_property
40+ def _mapping (self ):
41+ return {
42+ self ._key_for (ep ): dist
43+ for dist in distributions ()
44+ for ep in dist .entry_points
45+ }
4046
4147 def dist_for (self , entry_point : EntryPoint ):
4248 dist = getattr (entry_point , "dist" , None )
4349 if dist :
4450 return dist
4551
46- if self ._mapping is None :
47- self ._mapping = {
48- self ._key_for (ep ): dist
49- for ep in dist .entry_points
50- for dist in distributions ()
51- }
52-
53- return self ._mapping .get (self ._key_for (entry_point ))
54-
55- @staticmethod
56- def _key_for (entry_point : EntryPoint ):
57- return f"{ entry_point .group } :{ entry_point .name } :{ entry_point .value } "
52+ key = f"{ entry_point .group } :{ entry_point .name } :{ entry_point .value } "
53+ return self ._mapping .get (key )
5854
5955
6056def _load_distro () -> BaseDistro :
You can’t perform that action at this time.
0 commit comments