7
7
8
8
from ddtrace import Tracer
9
9
from ddtrace import tracer
10
- from ddtrace .constants import AUTO_KEEP
11
- from ddtrace .constants import SAMPLING_PRIORITY_KEY
12
- from ddtrace .constants import USER_KEEP
13
10
from tests .integration .utils import AGENT_VERSION
14
11
from tests .integration .utils import mark_snapshot
15
12
from tests .integration .utils import parametrize_with_all_encodings
21
18
22
19
23
20
@snapshot (include_tracer = True )
21
+ @pytest .mark .subprocess ()
24
22
def test_single_trace_single_span (tracer ):
23
+ from ddtrace import tracer
24
+
25
25
s = tracer .trace ("operation" , service = "my-svc" )
26
26
s .set_tag ("k" , "v" )
27
27
# numeric tag
@@ -33,7 +33,10 @@ def test_single_trace_single_span(tracer):
33
33
34
34
35
35
@snapshot (include_tracer = True )
36
+ @pytest .mark .subprocess ()
36
37
def test_multiple_traces (tracer ):
38
+ from ddtrace import tracer
39
+
37
40
with tracer .trace ("operation1" , service = "my-svc" ) as s :
38
41
s .set_tag ("k" , "v" )
39
42
s .set_tag ("num" , 1234 )
@@ -125,7 +128,6 @@ def test_tracer_trace_across_popen():
125
128
the child span has does not have '_dd.p.dm' shows that sampling was run
126
129
before fork automatically.
127
130
"""
128
- tracer = Tracer ()
129
131
130
132
def task (tracer ):
131
133
with tracer .trace ("child" ):
@@ -148,7 +150,6 @@ def test_tracer_trace_across_multiple_popens():
148
150
the child span has does not have '_dd.p.dm' shows that sampling was run
149
151
before fork automatically.
150
152
"""
151
- tracer = Tracer ()
152
153
153
154
def task (tracer ):
154
155
def task2 (tracer ):
@@ -170,9 +171,13 @@ def task2(tracer):
170
171
171
172
172
173
@snapshot ()
174
+ @pytest .mark .subprocess ()
173
175
def test_wrong_span_name_type_not_sent ():
174
176
"""Span names should be a text type."""
175
- tracer = Tracer ()
177
+ import mock
178
+
179
+ from ddtrace import tracer
180
+
176
181
with mock .patch ("ddtrace._trace.span.log" ) as log :
177
182
with tracer .trace (123 ):
178
183
pass
@@ -188,11 +193,9 @@ def test_wrong_span_name_type_not_sent():
188
193
],
189
194
)
190
195
@pytest .mark .parametrize ("encoding" , ["v0.4" , "v0.5" ])
191
- @snapshot ()
192
196
def test_trace_with_wrong_meta_types_not_sent (encoding , meta , monkeypatch ):
193
197
"""Wrong meta types should raise TypeErrors during encoding and fail to send to the agent."""
194
198
with override_global_config (dict (_trace_api = encoding )):
195
- tracer = Tracer ()
196
199
with mock .patch ("ddtrace._trace.span.log" ) as log :
197
200
with tracer .trace ("root" ) as root :
198
201
root ._meta = meta
@@ -211,8 +214,6 @@ def test_trace_with_wrong_meta_types_not_sent(encoding, meta, monkeypatch):
211
214
],
212
215
)
213
216
@pytest .mark .parametrize ("encoding" , ["v0.4" , "v0.5" ])
214
- @snapshot ()
215
- @pytest .mark .xfail
216
217
def test_trace_with_wrong_metrics_types_not_sent (encoding , metrics , monkeypatch ):
217
218
"""Wrong metric types should raise TypeErrors during encoding and fail to send to the agent."""
218
219
with override_global_config (dict (_trace_api = encoding )):
@@ -226,9 +227,14 @@ def test_trace_with_wrong_metrics_types_not_sent(encoding, metrics, monkeypatch)
226
227
log .exception .assert_called_once_with ("error closing trace" )
227
228
228
229
229
- @snapshot ()
230
+ @pytest .mark .subprocess ()
231
+ @pytest .mark .snapshot ()
230
232
def test_tracetagsprocessor_only_adds_new_tags ():
231
- tracer = Tracer ()
233
+ from ddtrace import tracer
234
+ from ddtrace .constants import AUTO_KEEP
235
+ from ddtrace .constants import SAMPLING_PRIORITY_KEY
236
+ from ddtrace .constants import USER_KEEP
237
+
232
238
with tracer .trace (name = "web.request" ) as span :
233
239
span .context .sampling_priority = AUTO_KEEP
234
240
span .set_metric (SAMPLING_PRIORITY_KEY , USER_KEEP )
0 commit comments