Skip to content

Commit

Permalink
load_distro
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydvoss committed Jun 23, 2023
1 parent 9b7b0ba commit d4a3b98
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
_logger = getLogger(__name__)


def _load_distros() -> BaseDistro:
def _load_distro() -> BaseDistro:
distro_name = environ.get(OTEL_PYTHON_DISTRO, None)
for entry_point in iter_entry_points("opentelemetry_distro"):
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from opentelemetry.instrumentation.auto_instrumentation._load import (
_load_configurators,
_load_distros,
_load_distro,
_load_instrumentors,
)
from opentelemetry.instrumentation.utils import _python_path_without_directory
Expand All @@ -33,7 +33,7 @@ def initialize():
)

try:
distro = _load_distros()
distro = _load_distro()
distro.configure()
_load_configurators()
_load_instrumentors(distro)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_load_configurators_error(self, iter_mock):
@patch(
"opentelemetry.instrumentation.auto_instrumentation._load.iter_entry_points"
)
def test_load_distros(self, iter_mock, isinstance_mock):
def test_load_distro(self, iter_mock, isinstance_mock):
# Add multiple entry points but only specify the 2nd in the environment variable.
ep_mock1 = Mock()
ep_mock1.name = "custom_distro1"
Expand All @@ -121,7 +121,7 @@ def test_load_distros(self, iter_mock, isinstance_mock):
# Mock entry points to be instances of BaseDistro.
isinstance_mock.return_value = True
self.assertEqual(
_load._load_distros(),
_load._load_distro(),
distro_mock2(),
)

Expand All @@ -135,7 +135,7 @@ def test_load_distros(self, iter_mock, isinstance_mock):
@patch(
"opentelemetry.instrumentation.auto_instrumentation._load.iter_entry_points"
)
def test_load_distros_not_distro(
def test_load_distro_not_distro(
self, iter_mock, default_distro_mock, isinstance_mock
):
# Add multiple entry points but only specify the 2nd in the environment variable.
Expand All @@ -156,7 +156,7 @@ def test_load_distros_not_distro(
# Confirm default distro is used if specified entry point is not a BaseDistro
isinstance_mock.return_value = False
self.assertEqual(
_load._load_distros(),
_load._load_distro(),
default_distro_mock(),
)

Expand All @@ -167,11 +167,11 @@ def test_load_distros_not_distro(
@patch(
"opentelemetry.instrumentation.auto_instrumentation._load.iter_entry_points"
)
def test_load_distros_no_ep(self, iter_mock, default_distro_mock):
def test_load_distro_no_ep(self, iter_mock, default_distro_mock):
iter_mock.return_value = ()
# Confirm default distro is used if there are no entry points.
self.assertEqual(
_load._load_distros(),
_load._load_distro(),
default_distro_mock(),
)

Expand All @@ -182,7 +182,7 @@ def test_load_distros_no_ep(self, iter_mock, default_distro_mock):
@patch(
"opentelemetry.instrumentation.auto_instrumentation._load.iter_entry_points"
)
def test_load_distros_error(self, iter_mock, isinstance_mock):
def test_load_distro_error(self, iter_mock, isinstance_mock):
ep_mock1 = Mock()
ep_mock1.name = "custom_distro1"
distro_mock1 = Mock()
Expand All @@ -200,7 +200,7 @@ def test_load_distros_error(self, iter_mock, isinstance_mock):
iter_mock.return_value = (ep_mock1, ep_mock2, ep_mock3)
isinstance_mock.return_value = True
# Confirm method raises exception if it fails to load a distro.
self.assertRaises(Exception, _load._load_distros)
self.assertRaises(Exception, _load._load_distro)

@patch.dict(
"os.environ",
Expand Down

0 comments on commit d4a3b98

Please sign in to comment.