Skip to content

Commit 9a27b8f

Browse files
authored
feat(tracer): re-enable v05 trace encoding (#7878)
Follow up to: #7874 ## Checklist - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed. If no release note is required, add label `changelog/no-changelog`. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [ ] Title is accurate. - [ ] No unnecessary changes are introduced. - [ ] Description motivates each change. - [ ] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [ ] Testing strategy adequately addresses listed risk(s). - [ ] Change is maintainable (easy to change, telemetry, documentation). - [ ] Release note makes sense to a user of the library. - [ ] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. - [ ] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) - [ ] If this PR touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from `@DataDog/security-design-and-guidance`. - [ ] This PR doesn't touch any of that.
1 parent 27770dc commit 9a27b8f

File tree

519 files changed

+3333
-355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

519 files changed

+3333
-355
lines changed

ddtrace/internal/writer/writer.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
from ..encoding import JSONEncoderV2
3636
from ..logger import get_logger
3737
from ..runtime import container
38+
from ..serverless import in_azure_function_consumption_plan
39+
from ..serverless import in_gcp_function
3840
from ..sma import SimpleMovingAverage
3941
from .writer_client import WRITER_CLIENTS
4042
from .writer_client import AgentWriterClientV3
@@ -478,7 +480,11 @@ def __init__(
478480
# https://docs.python.org/3/library/sys.html#sys.platform
479481
is_windows = sys.platform.startswith("win") or sys.platform.startswith("cygwin")
480482

481-
self._api_version = api_version or config._trace_api or ("v0.4" if priority_sampling else "v0.3")
483+
default_api_version = "v0.5"
484+
if is_windows or in_gcp_function() or in_azure_function_consumption_plan():
485+
default_api_version = "v0.4"
486+
487+
self._api_version = api_version or config._trace_api or default_api_version
482488
if is_windows and self._api_version == "v0.5":
483489
raise RuntimeError(
484490
"There is a known compatibility issue with v0.5 API and Windows, "

docs/configuration.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ The following environment variables for the tracer are supported:
287287

288288
DD_TRACE_API_VERSION:
289289
default: |
290-
``v0.4``
290+
``v0.5``
291291
description: |
292292
The trace API version to use when sending traces to the Datadog agent.
293293

@@ -296,6 +296,7 @@ The following environment variables for the tracer are supported:
296296
v0.56.0:
297297
v1.7.0: default changed to ``v0.5``.
298298
v1.19.1: default reverted to ``v0.4``.
299+
v2.4.0: default changed to ``v0.5``.
299300

300301
DD_TRACE_OBFUSCATION_QUERY_STRING_REGEXP:
301302
default: |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
other:
3+
- |
4+
tracing: Upgrades the trace encoding format to v0.5. This change improves the performance of encoding and sending spans.

tests/integration/test_integration.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def test_uds_wrong_socket_path():
127127
mock.call(
128128
"failed to send, dropping %d traces to intake at %s after %d retries",
129129
1,
130-
"unix:///tmp/ddagent/nosockethere/{}/traces".format(encoding if encoding else "v0.4"),
130+
"unix:///tmp/ddagent/nosockethere/{}/traces".format(encoding if encoding else "v0.5"),
131131
3,
132132
)
133133
]
@@ -403,7 +403,7 @@ def test_trace_generates_error_logs_when_hostname_invalid():
403403
mock.call(
404404
"failed to send, dropping %d traces to intake at %s after %d retries",
405405
1,
406-
"http://bad:1111/{}/traces".format(encoding if encoding else "v0.4"),
406+
"http://bad:1111/{}/traces".format(encoding if encoding else "v0.5"),
407407
3,
408408
)
409409
]
@@ -492,7 +492,7 @@ def test_trace_with_invalid_payload_generates_error_log():
492492
[
493493
mock.call(
494494
"failed to send traces to intake at %s: HTTP error status %s, reason %s",
495-
"http://localhost:8126/v0.4/traces",
495+
"http://localhost:8126/v0.5/traces",
496496
400,
497497
"Bad Request",
498498
)
@@ -571,7 +571,7 @@ def test_api_version_downgrade_generates_no_warning_logs():
571571

572572
from ddtrace import tracer as t
573573

574-
encoding = os.environ["DD_TRACE_API_VERSION"] or "v0.4"
574+
encoding = os.environ["DD_TRACE_API_VERSION"] or "v0.5"
575575
t._writer._downgrade(None, None, t._writer._clients[0])
576576
assert t._writer._endpoint == {"v0.5": "v0.4/traces", "v0.4": "v0.3/traces"}[encoding]
577577
with mock.patch("ddtrace.internal.writer.writer.log") as log:

tests/snapshots/test_extended_sampling_resource.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
[[
22
{
33
"name": "should_not_send",
4-
"service": null,
4+
"service": "",
55
"resource": "mycoolre$ource",
66
"trace_id": 0,
77
"span_id": 1,
88
"parent_id": 0,
9+
"type": "",
10+
"error": 0,
911
"meta": {
1012
"_dd.p.dm": "-3",
1113
"language": "python",
@@ -24,11 +26,13 @@
2426
[
2527
{
2628
"name": "should_send",
27-
"service": null,
29+
"service": "",
2830
"resource": "something else",
2931
"trace_id": 1,
3032
"span_id": 1,
3133
"parent_id": 0,
34+
"type": "",
35+
"error": 0,
3236
"meta": {
3337
"_dd.p.dm": "-0",
3438
"language": "python",

tests/snapshots/test_extended_sampling_tags.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
[[
22
{
33
"name": "should_not_send",
4-
"service": null,
4+
"service": "",
55
"resource": "should_not_send",
66
"trace_id": 0,
77
"span_id": 1,
88
"parent_id": 0,
9+
"type": "",
10+
"error": 0,
911
"meta": {
1012
"_dd.p.dm": "-3",
1113
"language": "python",
@@ -25,11 +27,13 @@
2527
[
2628
{
2729
"name": "should_send",
28-
"service": null,
30+
"service": "",
2931
"resource": "should_send",
3032
"trace_id": 1,
3133
"span_id": 1,
3234
"parent_id": 0,
35+
"type": "",
36+
"error": 0,
3337
"meta": {
3438
"_dd.p.dm": "-0",
3539
"banana": "True",

tests/snapshots/test_extended_sampling_tags_and_resource.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
[[
22
{
33
"name": "should_not_send",
4-
"service": null,
4+
"service": "",
55
"resource": "mycoolre$ource",
66
"trace_id": 0,
77
"span_id": 1,
88
"parent_id": 0,
9+
"type": "",
10+
"error": 0,
911
"meta": {
1012
"_dd.p.dm": "-3",
1113
"language": "python",
@@ -25,11 +27,13 @@
2527
[
2628
{
2729
"name": "should_send1",
28-
"service": null,
30+
"service": "",
2931
"resource": "should_send1",
3032
"trace_id": 1,
3133
"span_id": 1,
3234
"parent_id": 0,
35+
"type": "",
36+
"error": 0,
3337
"meta": {
3438
"_dd.p.dm": "-0",
3539
"banana": "True",
@@ -48,11 +52,13 @@
4852
[
4953
{
5054
"name": "should_send2",
51-
"service": null,
55+
"service": "",
5256
"resource": "banana",
5357
"trace_id": 2,
5458
"span_id": 1,
5559
"parent_id": 0,
60+
"type": "",
61+
"error": 0,
5662
"meta": {
5763
"_dd.p.dm": "-0",
5864
"language": "python",
@@ -71,11 +77,13 @@
7177
[
7278
{
7379
"name": "should_send3",
74-
"service": null,
80+
"service": "",
7581
"resource": "mycoolre$ource",
7682
"trace_id": 3,
7783
"span_id": 1,
7884
"parent_id": 0,
85+
"type": "",
86+
"error": 0,
7987
"meta": {
8088
"_dd.p.dm": "-0",
8189
"banana": "True",

tests/snapshots/test_extended_sampling_tags_glob.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
[[
22
{
33
"name": "should_not_send",
4-
"service": null,
4+
"service": "",
55
"resource": "should_not_send",
66
"trace_id": 0,
77
"span_id": 1,
88
"parent_id": 0,
9+
"type": "",
10+
"error": 0,
911
"meta": {
1012
"_dd.p.dm": "-3",
1113
"language": "python",
@@ -25,11 +27,13 @@
2527
[
2628
{
2729
"name": "should_send",
28-
"service": null,
30+
"service": "",
2931
"resource": "should_send",
3032
"trace_id": 1,
3133
"span_id": 1,
3234
"parent_id": 0,
35+
"type": "",
36+
"error": 0,
3337
"meta": {
3438
"_dd.p.dm": "-0",
3539
"language": "python",

tests/snapshots/test_multi_trace.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
[[
22
{
33
"name": "root0",
4-
"service": null,
4+
"service": "",
55
"resource": "root0",
66
"trace_id": 0,
77
"span_id": 1,
88
"parent_id": 0,
9+
"type": "",
10+
"error": 0,
911
"meta": {
1012
"_dd.p.dm": "-0",
1113
"language": "python",
@@ -22,22 +24,26 @@
2224
},
2325
{
2426
"name": "child0",
25-
"service": null,
27+
"service": "",
2628
"resource": "child0",
2729
"trace_id": 0,
2830
"span_id": 2,
2931
"parent_id": 1,
32+
"type": "",
33+
"error": 0,
3034
"duration": 29000,
3135
"start": 1633030641740720000
3236
}],
3337
[
3438
{
3539
"name": "root1",
36-
"service": null,
40+
"service": "",
3741
"resource": "root1",
3842
"trace_id": 1,
3943
"span_id": 1,
4044
"parent_id": 0,
45+
"type": "",
46+
"error": 0,
4147
"meta": {
4248
"_dd.p.dm": "-0",
4349
"language": "python",
@@ -54,11 +60,13 @@
5460
},
5561
{
5662
"name": "child1",
57-
"service": null,
63+
"service": "",
5864
"resource": "child1",
5965
"trace_id": 1,
6066
"span_id": 2,
6167
"parent_id": 1,
68+
"type": "",
69+
"error": 0,
6270
"duration": 15000,
6371
"start": 1633030641741273000
6472
}]]

tests/snapshots/test_sampling_with_default_sample_rate_1.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
[[
22
{
33
"name": "trace2",
4-
"service": null,
4+
"service": "",
55
"resource": "trace2",
66
"trace_id": 0,
77
"span_id": 1,
88
"parent_id": 0,
9+
"type": "",
10+
"error": 0,
911
"meta": {
1012
"_dd.p.dm": "-3",
1113
"language": "python",
@@ -23,11 +25,13 @@
2325
},
2426
{
2527
"name": "child",
26-
"service": null,
28+
"service": "",
2729
"resource": "child",
2830
"trace_id": 0,
2931
"span_id": 2,
3032
"parent_id": 1,
33+
"type": "",
34+
"error": 0,
3135
"duration": 11602,
3236
"start": 1692637140104307759
3337
}]]

0 commit comments

Comments
 (0)