Skip to content

Commit

Permalink
Ensure that Datadog-Container-ID is not empty if present
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeauchesne committed Jan 16, 2024
1 parent 06e0244 commit f6b2ad8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
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)

0 comments on commit f6b2ad8

Please sign in to comment.