@@ -137,7 +137,11 @@ def test_uds_wrong_socket_path(encoding, monkeypatch):
137137 t .trace ("client.testing" ).finish ()
138138 t .shutdown ()
139139 calls = [
140- mock .call ("failed to send traces to Datadog Agent at %s" , "unix:///tmp/ddagent/nosockethere" , exc_info = True )
140+ mock .call (
141+ "failed to send traces to Datadog Agent at %s" ,
142+ "unix:///tmp/ddagent/nosockethere/{}/traces" .format (encoding if encoding else "v0.4" ),
143+ exc_info = True ,
144+ )
141145 ]
142146 log .error .assert_has_calls (calls )
143147
@@ -270,7 +274,13 @@ def test_trace_bad_url(encoding, monkeypatch):
270274 pass
271275 t .shutdown ()
272276
273- calls = [mock .call ("failed to send traces to Datadog Agent at %s" , "http://bad:1111" , exc_info = True )]
277+ calls = [
278+ mock .call (
279+ "failed to send traces to Datadog Agent at %s" ,
280+ "http://bad:1111/{}/traces" .format (encoding if encoding else "v0.4" ),
281+ exc_info = True ,
282+ )
283+ ]
274284 log .error .assert_has_calls (calls )
275285
276286
@@ -386,7 +396,7 @@ def encode_traces(self, traces):
386396 calls = [
387397 mock .call (
388398 "failed to send traces to Datadog Agent at %s: HTTP error status %s, reason %s" ,
389- "http://localhost:8126" ,
399+ "http://localhost:8126/v0.4/traces " ,
390400 400 ,
391401 "Bad Request" ,
392402 )
@@ -419,7 +429,7 @@ def encode_traces(self, traces):
419429 calls = [
420430 mock .call (
421431 "failed to send traces to Datadog Agent at %s: HTTP error status %s, reason %s, payload %s" ,
422- "http://localhost:8126" ,
432+ "http://localhost:8126/v0.4/traces " ,
423433 400 ,
424434 "Bad Request" ,
425435 "6261645f7061796c6f6164" ,
@@ -463,7 +473,7 @@ def encode_traces(self, traces):
463473 calls = [
464474 mock .call (
465475 "failed to send traces to Datadog Agent at %s: HTTP error status %s, reason %s, payload %s" ,
466- "http://localhost:8126" ,
476+ "http://localhost:8126/v0.4/traces " ,
467477 400 ,
468478 "Bad Request" ,
469479 "bad_payload" ,
@@ -548,13 +558,15 @@ def test_flush_log(caplog, encoding, monkeypatch):
548558 with mock .patch ("ddtrace.internal.writer.log" ) as log :
549559 writer .write ([])
550560 writer .flush_queue (raise_exc = True )
561+ # for latest agent, default to v0.3 since no priority sampler is set
562+ expected_encoding = "v0.3" if AGENT_VERSION == "v5" else (encoding or "v0.3" )
551563 calls = [
552564 mock .call (
553565 logging .DEBUG ,
554566 "sent %s in %.5fs to %s" ,
555567 AnyStr (),
556568 AnyFloat (),
557- writer .agent_url ,
569+ "{}/{}/traces" . format ( writer .agent_url , expected_encoding ) ,
558570 )
559571 ]
560572 log .log .assert_has_calls (calls )
0 commit comments