File tree Expand file tree Collapse file tree 3 files changed +36
-2
lines changed
ddtrace/contrib/mongoengine
tests/contrib/mongoengine Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 2424
2525with require_modules (required_modules ) as missing_modules :
2626 if not missing_modules :
27- from .patch import patch
27+ from .patch import patch , trace_mongoengine
28+
29+ __all__ = ['patch' , 'trace_mongoengine' ]
30+
2831
29- __all__ = ['patch' ]
Original file line number Diff line number Diff line change 11import mongoengine
22
33from .trace import WrappedConnect
4+ from ddtrace .util import deprecated
45
56# Original connect function
67_connect = mongoengine .connect
@@ -12,3 +13,7 @@ def patch():
1213def unpatch ():
1314 setattr (mongoengine , 'connect' , _connect )
1415
16+ @deprecated (message = 'Use patching instead (see the docs).' , version = '0.6.0' )
17+ def trace_mongoengine (* args , ** kwargs ):
18+ return _connect
19+
Original file line number Diff line number Diff line change 1+ """
2+ ensure old interfaces exist and won't break things.
3+ """
4+
5+
6+ import mongoengine
7+
8+ from tests .test_tracer import get_dummy_tracer
9+ from tests .contrib import config
10+
11+ class Singer (mongoengine .Document ):
12+ first_name = mongoengine .StringField (max_length = 50 )
13+ last_name = mongoengine .StringField (max_length = 50 )
14+
15+
16+ def test_less_than_v04 ():
17+ # interface from < v0.4
18+ from ddtrace .contrib .mongoengine import trace_mongoengine
19+ tracer = get_dummy_tracer ()
20+
21+ connect = trace_mongoengine (tracer , service = "my-mongo-db" , patch = False )
22+ connect (port = config .MONGO_CONFIG ['port' ])
23+
24+ lc = Singer ()
25+ lc .first_name = 'leonard'
26+ lc .last_name = 'cohen'
27+ lc .save ()
You can’t perform that action at this time.
0 commit comments