Skip to content

Commit

Permalink
Use opentelemertry importlib metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Sep 5, 2024
1 parent 1f3ff04 commit 5fe5a2c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import argparse
import logging
import sys
from importlib.metadata import PackageNotFoundError, version
from opentelemetry.util._importlib_metadata import (
PackageNotFoundError, version
)
from subprocess import (
PIPE,
CalledProcessError,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
from importlib.metadata import Distribution, PackageNotFoundError, version
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from opentelemetry.util._importlib_metadata import (
Distribution, PackageNotFoundError, version
)
from logging import getLogger
from typing import Collection, Optional, Union

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""

from abc import ABC, abstractmethod
from importlib.metadata import EntryPoint
from opentelemetry.util._importlib_metadata import EntryPoint
from logging import getLogger

from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
Expand Down
8 changes: 4 additions & 4 deletions opentelemetry-instrumentation/tests/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

# pylint: disable=protected-access

from importlib.metadata import Distribution, requires
from packaging.requirements import Requirement, InvalidRequirement
from opentelemetry.util._importlib_metadata import Distribution, requires
from packaging.requirements import Requirement
import pytest

from opentelemetry.instrumentation.dependencies import (
Expand Down Expand Up @@ -69,8 +69,8 @@ def test_get_dist_dependency_conflicts(self):
def mock_requires(extras=()):
if "instruments" in extras:
return requires(
'test-pkg ~= 1.0; extra == "instruments"'
)
'test-pkg ~= 1.0; extra == "instruments"'
)
return []

dist = Distribution()
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-instrumentation/tests/test_distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from unittest import TestCase

from importlib.metadata import EntryPoint
from opentelemetry.util._importlib_metadata import EntryPoint

from opentelemetry.instrumentation.distro import BaseDistro
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
Expand Down

0 comments on commit 5fe5a2c

Please sign in to comment.