Skip to content

Commit

Permalink
update pymongo instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv committed Jul 15, 2022
1 parent 07f63c0 commit 5370648
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,20 @@ def _instrument(self, **kwargs):
failed_hook = kwargs.get("failed_hook", dummy_callback)

# Create and register a CommandTracer only the first time
if self._commandtracer_instance is None:
if PymongoInstrumentor._commandtracer_instance is None:
tracer = get_tracer(__name__, __version__, tracer_provider)

self._commandtracer_instance = CommandTracer(
PymongoInstrumentor._commandtracer_instance = CommandTracer(
tracer,
request_hook=request_hook,
response_hook=response_hook,
failed_hook=failed_hook,
)
monitoring.register(self._commandtracer_instance)
monitoring.register(PymongoInstrumentor._commandtracer_instance)

# If already created, just enable it
self._commandtracer_instance.is_enabled = True
PymongoInstrumentor._commandtracer_instance.is_enabled = True

def _uninstrument(self, **kwargs):
if self._commandtracer_instance is not None:
self._commandtracer_instance.is_enabled = False
if PymongoInstrumentor._commandtracer_instance is not None:
PymongoInstrumentor._commandtracer_instance.is_enabled = False

0 comments on commit 5370648

Please sign in to comment.