File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
constants/instrumentation Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 1+ APIS = {
2+ "AGGREGATE" : {
3+ "METHOD" : "aggregate" ,
4+ "OPERATION" : "aggregate" ,
5+ },
6+ }
Original file line number Diff line number Diff line change 2121from importlib_metadata import version as v
2222from wrapt import wrap_function_wrapper as _W
2323from .patch import generic_patch
24+ from langtrace_python_sdk .constants .instrumentation .pymongo import APIS
2425
2526
2627class PyMongoInstrumentation (BaseInstrumentor ):
@@ -32,7 +33,15 @@ def instrumentation_dependencies(self) -> Collection[str]:
3233 return ["pymongo >= 4.0.0" ]
3334
3435 def _instrument (self , ** kwargs ):
35- pass
36+ tracer_provider = kwargs .get ("tracer_provider" )
37+ tracer = get_tracer (__name__ , "" , tracer_provider )
38+ version = v ("pymongo" )
39+ for api in APIS .values ():
40+ _W (
41+ module = "pymongo.collection" ,
42+ name = f"Collection.{ api ['METHOD' ]} " ,
43+ wrapper = generic_patch (version , tracer ),
44+ )
3645
3746 def _uninstrument (self , ** kwargs ):
3847 pass
You can’t perform that action at this time.
0 commit comments