Skip to content

Commit 5fe5a2c

Browse files
committed
Use opentelemertry importlib metadata
1 parent 1f3ff04 commit 5fe5a2c

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
import argparse
1616
import logging
1717
import sys
18-
from importlib.metadata import PackageNotFoundError, version
18+
from opentelemetry.util._importlib_metadata import (
19+
PackageNotFoundError, version
20+
)
1921
from subprocess import (
2022
PIPE,
2123
CalledProcessError,

opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
from importlib.metadata import Distribution, PackageNotFoundError, version
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from opentelemetry.util._importlib_metadata import (
16+
Distribution, PackageNotFoundError, version
17+
)
218
from logging import getLogger
319
from typing import Collection, Optional, Union
420

opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"""
1919

2020
from abc import ABC, abstractmethod
21-
from importlib.metadata import EntryPoint
21+
from opentelemetry.util._importlib_metadata import EntryPoint
2222
from logging import getLogger
2323

2424
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor

opentelemetry-instrumentation/tests/test_dependencies.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
# pylint: disable=protected-access
1616

17-
from importlib.metadata import Distribution, requires
18-
from packaging.requirements import Requirement, InvalidRequirement
17+
from opentelemetry.util._importlib_metadata import Distribution, requires
18+
from packaging.requirements import Requirement
1919
import pytest
2020

2121
from opentelemetry.instrumentation.dependencies import (
@@ -69,8 +69,8 @@ def test_get_dist_dependency_conflicts(self):
6969
def mock_requires(extras=()):
7070
if "instruments" in extras:
7171
return requires(
72-
'test-pkg ~= 1.0; extra == "instruments"'
73-
)
72+
'test-pkg ~= 1.0; extra == "instruments"'
73+
)
7474
return []
7575

7676
dist = Distribution()

opentelemetry-instrumentation/tests/test_distro.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from unittest import TestCase
1717

18-
from importlib.metadata import EntryPoint
18+
from opentelemetry.util._importlib_metadata import EntryPoint
1919

2020
from opentelemetry.instrumentation.distro import BaseDistro
2121
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor

0 commit comments

Comments
 (0)