Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/5441.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`opentelemetry-sdk`: fix `TypeError` when instantiating a `_BaseConfigurator` subclass whose `__init__` takes arguments
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ class _BaseConfigurator(ABC):

def __new__(cls, *args, **kwargs):
if cls._instance is None:
cls._instance = object.__new__(cls, *args, **kwargs)
cls._instance = object.__new__(cls)

return cls._instance

Expand Down
15 changes: 15 additions & 0 deletions opentelemetry-sdk/tests/test_configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,21 @@ def test_custom_configurator(self, mock_init_comp):
}
mock_init_comp.assert_called_once_with(**kwargs)

def test_custom_configurator_with_init_args(self):
class ConfiguratorWithArgs(_OTelSDKConfigurator):
def __init__(self, name, strict=False):
super().__init__()
self.name = name
self.strict = strict

def _configure(self, **kwargs):
pass

configurator = ConfiguratorWithArgs("TEST_NAME", strict=True)
self.assertEqual(configurator.name, "TEST_NAME")
self.assertTrue(configurator.strict)
self.assertIs(configurator, ConfiguratorWithArgs("TEST_NAME"))


# Any test that calls _init_logging with setup_logging_handler=True
# should call _init_logging within this context manager, to
Expand Down
Loading