Skip to content
Open
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
8 changes: 5 additions & 3 deletions shim/opentelemetry-opencensus-shim/tests/test_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ def test_install_shim(self):
self.assertIsInstance(Tracer.tracer, property)

def test_install_shim_affects_existing_tracers(self):
# Initially the shim is not installed. A OC Tracer instance should have a NoopTracer
# Initially the shim is not installed. Store the original tracer instance.
oc_tracer = Tracer()
self.assertIsInstance(oc_tracer.tracer, NoopTracer)
self.assertNotIsInstance(oc_tracer.tracer, ShimTracer)
original_tracer = oc_tracer.tracer
self.assertNotIsInstance(original_tracer, ShimTracer)
Comment on lines +45 to +46
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we do this instead of creating a tracer instance?

Suggested change
original_tracer = oc_tracer.tracer
self.assertNotIsInstance(original_tracer, ShimTracer)
self.assertNotIsInstance(oc_tracer.tracer, ShimTracer)


install_shim()

# The property should cause existing instances to get the singleton ShimTracer
self.assertIsInstance(oc_tracer.tracer, ShimTracer)
# The ShimTracer wraps a NoopTracer, which should look like a NoopTracer
self.assertIsInstance(oc_tracer.tracer, NoopTracer)

def test_install_shim_affects_new_tracers(self):
install_shim()
Expand Down
Loading