mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-08-02 11:31:52 +08:00
Stop multiple calls to AsyncPGInstrumentor.__init__ from clobbering instance attributes (#1791)
* Stop multiple calls to AsyncPGInstrumentor.__init__ from clobbering instance tracer attribute * Remove class-level initialisation of _tracer * Fix regex * Add to changelog * Fix lint errors * Update CHANGELOG.md Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com> * Set tracer in class definition to avoid lint error --------- Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com> Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
This commit is contained in:
@ -5,7 +5,7 @@ from opentelemetry.test.test_base import TestBase
|
||||
|
||||
|
||||
class TestAsyncPGInstrumentation(TestBase):
|
||||
def test_duplicated_instrumentation(self):
|
||||
def test_duplicated_instrumentation_can_be_uninstrumented(self):
|
||||
AsyncPGInstrumentor().instrument()
|
||||
AsyncPGInstrumentor().instrument()
|
||||
AsyncPGInstrumentor().instrument()
|
||||
@ -16,6 +16,14 @@ class TestAsyncPGInstrumentation(TestBase):
|
||||
hasattr(method, "_opentelemetry_ext_asyncpg_applied")
|
||||
)
|
||||
|
||||
def test_duplicated_instrumentation_works(self):
|
||||
first = AsyncPGInstrumentor()
|
||||
first.instrument()
|
||||
second = AsyncPGInstrumentor()
|
||||
second.instrument()
|
||||
self.assertIsNotNone(first._tracer)
|
||||
self.assertIsNotNone(second._tracer)
|
||||
|
||||
def test_duplicated_uninstrumentation(self):
|
||||
AsyncPGInstrumentor().instrument()
|
||||
AsyncPGInstrumentor().uninstrument()
|
||||
|
Reference in New Issue
Block a user