Skip to content

Commit 2b05ee8

Browse files
committed
improve tests
1 parent e03aa8d commit 2b05ee8

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

tests/debugging/test_encoding.py

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -270,34 +270,39 @@ def test_process_tags_are_not_included_by_default():
270270
assert "process_tags" not in decoded[0]
271271

272272

273+
@pytest.mark.subprocess(
274+
env=dict(
275+
DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED="true",
276+
)
277+
)
273278
def test_process_tags_are_included():
274-
from ddtrace.internal.settings._config import config
275-
from tests.utils import process_tag_reload
279+
import inspect
280+
import json
281+
import threading
276282

277-
try:
278-
config._process_tags_enabled = True
279-
process_tag_reload()
280-
s = Snapshot(
281-
probe=create_snapshot_line_probe(probe_id="batch-test", source_file="foo.py", line=42),
282-
frame=inspect.currentframe(),
283-
thread=threading.current_thread(),
284-
)
285-
buffer_size = 30 * (1 << 20)
286-
queue = SignalQueue(encoder=LogSignalJsonEncoder(None), buffer_size=buffer_size)
287-
288-
s.line({})
289-
290-
queue = SignalQueue(encoder=LogSignalJsonEncoder("test-service"))
291-
queue.put(s)
292-
data = queue.flush()
293-
assert data is not None
294-
payload, _ = data
295-
decoded = json.loads(payload.decode())
296-
297-
assert "process_tags" in decoded[0]
298-
finally:
299-
config._process_tags_enabled = False
300-
process_tag_reload()
283+
from ddtrace.debugging._encoding import LogSignalJsonEncoder
284+
from ddtrace.debugging._encoding import SignalQueue
285+
from ddtrace.debugging._signal.snapshot import Snapshot
286+
from tests.debugging.utils import create_snapshot_line_probe
287+
288+
s = Snapshot(
289+
probe=create_snapshot_line_probe(probe_id="batch-test", source_file="foo.py", line=42),
290+
frame=inspect.currentframe(),
291+
thread=threading.current_thread(),
292+
)
293+
buffer_size = 30 * (1 << 20)
294+
queue = SignalQueue(encoder=LogSignalJsonEncoder(None), buffer_size=buffer_size)
295+
296+
s.line({})
297+
298+
queue = SignalQueue(encoder=LogSignalJsonEncoder("test-service"))
299+
queue.put(s)
300+
data = queue.flush()
301+
assert data is not None
302+
payload, _ = data
303+
decoded = json.loads(payload.decode())
304+
305+
assert "process_tags" in decoded[0]
301306

302307

303308
def test_batch_flush_reencode():

0 commit comments

Comments
 (0)