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

Ensure that Datadog-Container-ID is not empty if present #2021

Merged
merged 1 commit into from
Jan 16, 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
2 changes: 2 additions & 0 deletions manifests/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ tests/:
Test_RemoteConfigurationUpdateSequenceFeaturesNoCache: irrelevant (cache is implemented)
Test_RemoteConfigurationUpdateSequenceLiveDebugging: missing_feature
Test_RemoteConfigurationUpdateSequenceLiveDebuggingNoCache: irrelevant (cache is implemented)
test_data_integrity.py:
Test_LibraryHeaders: missing_feature (Datadog-Container-ID is empty on telemetry payloads)
test_distributed.py:
Test_DistributedHttp: missing_feature
test_identify.py:
Expand Down
19 changes: 16 additions & 3 deletions tests/test_data_integrity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright 2021 Datadog, Inc.

"""Misc checks around data integrity during components' lifetime"""
from utils import weblog, interfaces, context, bug, rfc, scenarios, missing_feature
from utils import weblog, interfaces, context, bug, rfc, missing_feature
from utils.tools import logger
from utils.cgroup_info import get_container_id

Expand Down Expand Up @@ -41,7 +41,7 @@ def check_condition(data):
)

def test_trace_header_diagnostic_check(self):
""" x-datadog-diagnostic-check header is present iif content is empty """
"""x-datadog-diagnostic-check header is present iif content is empty"""

def validator(data):
request_headers = {h[0].lower() for h in data["request"]["headers"]}
Expand Down Expand Up @@ -91,7 +91,6 @@ def test_trace_header_container_tags(self):
logger.info(f"cgroup: weblog container id is {weblog_container_id}")

def validator(data):

if "content" not in data["request"] or not data["request"]["content"]:
# RFC states "Once container ID is stored locally in the tracer,
# it must be sent to the Agent every time traces are sent."
Expand Down Expand Up @@ -121,3 +120,17 @@ def validator(data):
)

interfaces.library.add_traces_validation(validator, success_by_default=True)


class Test_LibraryHeaders:
"""Misc test around headers sent by libraries"""

def test_datadog_container_id(self):
"""Datadog-Container-ID header is not empty if present"""

def validator(data):
for header, value in data["request"]["headers"]:
if header.lower() == "datadog-container-id":
assert value, "Datadog-Container-ID header is empty"

interfaces.library.validate(validator, success_by_default=True)
Loading