Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[weblog] Add test for Datadog distributed tracing headers where x-datadog parent-id is set to 0 #3564

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions manifests/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ tests/:
Test_LibraryHeaders: v1.60.0.dev0
test_distributed.py:
Test_DistributedHttp: missing_feature
Test_Synthetics_APM_Datadog: bug (APMAPI-901) # the incoming headers are considered invalid
test_identify.py:
Test_Basic: v1.37.0
Test_Propagate: v1.48.0-rc.1
Expand Down
3 changes: 3 additions & 0 deletions manifests/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,9 @@ tests/:
Test_Config_UnifiedServiceTagging_Default: *ref_5_25_0
test_distributed.py:
Test_DistributedHttp: missing_feature
Test_Synthetics_APM_Datadog:
'*': *ref_5_25_0
nextjs: bug (APMAPI-939) # the nextjs weblog application changes the sampling priority from 1.0 to 2.0
test_identify.py:
Test_Basic: v2.4.0
Test_Propagate: *ref_3_2_0
Expand Down
49 changes: 49 additions & 0 deletions tests/test_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright 2022 Datadog, Inc.

import json
from utils.parametric.spec.trace import SAMPLING_PRIORITY_KEY, ORIGIN
from utils import weblog, interfaces, scenarios, features


Expand All @@ -25,3 +26,51 @@ def test_main(self):
assert "x-datadog-sampling-priority" not in data["request_headers"]
assert "x-datadog-tags" not in data["request_headers"]
assert "x-datadog-trace-id" not in data["request_headers"]


@scenarios.default
@features.datadog_headers_propagation
class Test_Synthetics_APM_Datadog:
def setup_synthetics(self):
self.r = weblog.get(
"/",
headers={
"x-datadog-trace-id": "1234567890",
"x-datadog-parent-id": "0",
"x-datadog-sampling-priority": "1",
"x-datadog-origin": "synthetics",
},
)

def test_synthetics(self):
interfaces.library.assert_trace_exists(self.r)
spans = interfaces.agent.get_spans_list(self.r)
assert len(spans) == 1, "Agent received the incorrect amount of spans"

span = spans[0]
assert span.get("traceID") == "1234567890"
assert "parentID" not in span or span.get("parentID") == 0 or span.get("parentID") is None
assert span.get("meta")[ORIGIN] == "synthetics"
assert span.get("metrics")[SAMPLING_PRIORITY_KEY] == 1

def setup_synthetics_browser(self):
self.r = weblog.get(
"/",
headers={
"x-datadog-trace-id": "1234567891",
"x-datadog-parent-id": "0",
"x-datadog-sampling-priority": "1",
"x-datadog-origin": "synthetics-browser",
},
)

def test_synthetics_browser(self):
interfaces.library.assert_trace_exists(self.r)
spans = interfaces.agent.get_spans_list(self.r)
assert len(spans) == 1, "Agent received the incorrect amount of spans"

span = spans[0]
assert span.get("traceID") == "1234567891"
assert "parentID" not in span or span.get("parentID") == 0 or span.get("parentID") is None
assert span.get("meta")[ORIGIN] == "synthetics-browser"
assert span.get("metrics")[SAMPLING_PRIORITY_KEY] == 1
Loading