You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py
+83-5Lines changed: 83 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,6 @@
26
26
from pymongo import MongoClient
27
27
from opentelemetry.instrumentation.pymongo import PymongoInstrumentor
28
28
29
-
30
29
PymongoInstrumentor().instrument()
31
30
client = MongoClient()
32
31
db = client["MongoDB_Database"]
@@ -35,9 +34,47 @@
35
34
36
35
API
37
36
---
38
-
"""
37
+
The `instrument` method accepts the following keyword args:
38
+
39
+
tracer_provider (TracerProvider) - an optional tracer provider
40
+
request_hook (Callable) -
41
+
a function with extra user-defined logic to be performed before querying mongodb
42
+
this function signature is: def request_hook(span: Span, event: CommandStartedEvent) -> None
43
+
response_hook (Callable) -
44
+
a function with extra user-defined logic to be performed after the query returns with a successful response
45
+
this function signature is: def response_hook(span: Span, event: CommandSucceededEvent) -> None
46
+
failed_hook (Callable) -
47
+
a function with extra user-defined logic to be performed after the query returns with a failed response
48
+
this function signature is: def failed_hook(span: Span, event: CommandFailedEvent) -> None
49
+
50
+
for example:
51
+
52
+
.. code: python
53
+
54
+
from opentelemetry.instrumentation.pymongo import PymongoInstrumentor
0 commit comments