Skip to content

Commit 1688b25

Browse files
feat: support LINEAGE field on x-ray trace ID (#310)
* feat: support LINEAGE field on x-ray trace ID * fix: flake8 did not like my comment length * feat: temporarily comment out test * Update tests/test_cold_start.py Co-authored-by: Rey Abolofia <purple4reina@gmail.com> * feat: use xtest instead of comment * feat: black --------- Co-authored-by: Rey Abolofia <purple4reina@gmail.com>
1 parent 5ce443b commit 1688b25

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

datadog_lambda/xray.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ def build_segment_payload(payload):
4545

4646

4747
def parse_xray_header(raw_trace_id):
48-
# Example: Root=1-5e272390-8c398be037738dc042009320;Parent=94ae789b969f1cc5;Sampled=1
48+
# Example:
49+
# Root=1-5e272390-8c398be037738dc042009320;Parent=94ae789b969f1cc5;Sampled=1;Lineage=c6c5b1b9:0
4950
logger.debug("Reading trace context from env var %s", raw_trace_id)
5051
if len(raw_trace_id) == 0:
5152
return None
5253
parts = raw_trace_id.split(";")
53-
if len(parts) != 3:
54+
if len(parts) < 3:
5455
return None
5556
root = parts[0].replace("Root=", "")
5657
parent = parts[1].replace("Parent=", "")

tests/test_cold_start.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def find_spec(*args, **kwargs):
4343
meta_path.pop()
4444
os.environ["DD_COLD_START_TRACING"] = "true"
4545

46-
def test_exec_module_failure_case(self):
46+
def xtest_exec_module_failure_case(self):
4747
mock_importer = MagicMock()
4848
mock_module_spec = MagicMock()
4949
mock_module_spec.name = "test_name"

tests/test_xray.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_send_segment_sampled_out(self):
3737
os.environ["AWS_XRAY_DAEMON_ADDRESS"] = "fake-agent.com:8080"
3838
os.environ[
3939
"_X_AMZN_TRACE_ID"
40-
] = "Root=1-5e272390-8c398be037738dc042009320;Parent=94ae789b969f1cc5;Sampled=0"
40+
] = "Root=1-5e272390-8c398be037738dc042009320;Parent=94ae789b969f1cc5;Sampled=0;Lineage=c6c5b1b9:0"
4141

4242
with patch(
4343
"datadog_lambda.xray.send", MagicMock(return_value=None)
@@ -50,7 +50,7 @@ def test_send_segment_sampled(self):
5050
os.environ["AWS_XRAY_DAEMON_ADDRESS"] = "fake-agent.com:8080"
5151
os.environ[
5252
"_X_AMZN_TRACE_ID"
53-
] = "Root=1-5e272390-8c398be037738dc042009320;Parent=94ae789b969f1cc5;Sampled=1"
53+
] = "Root=1-5e272390-8c398be037738dc042009320;Parent=94ae789b969f1cc5;Sampled=1;Lineage=c6c5b1b9:0"
5454
with patch(
5555
"datadog_lambda.xray.send", MagicMock(return_value=None)
5656
) as mock_send:

0 commit comments

Comments
 (0)