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

Move span pointer to inferred (root) span #552

Merged
merged 5 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion datadog_lambda/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1368,8 +1368,9 @@ def create_function_execution_span(
if parent_span:
span.parent_id = parent_span.span_id
if span_pointers:
root_span = parent_span if parent_span else span
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nano-nit: is root_span the right name? should this be target_span or something?

Copy link
Contributor Author

@nhulston nhulston Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be either; I think root_span makes sense because in the case of S3, the parent_span is the root span if it exists; if it doesn't exist, then the span is the root span of the trace

for span_pointer_description in span_pointers:
span._add_span_pointer(
root_span._add_span_pointer(
pointer_kind=span_pointer_description.pointer_kind,
pointer_direction=span_pointer_description.pointer_direction,
pointer_hash=span_pointer_description.pointer_hash,
Expand Down
90 changes: 45 additions & 45 deletions tests/integration/snapshots/logs/async-metrics_python310.log
Original file line number Diff line number Diff line change
Expand Up @@ -249,37 +249,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"_dd.top_level": 1,
"_sampling_priority_v1": 1
},
"type": "web"
},
{
"trace_id": "XXXX",
"parent_id": "XXXX",
"span_id": "XXXX",
"service": "aws.lambda",
"resource": "integration-tests-python-XXXX-async-metrics_python310",
"name": "aws.lambda",
"error": 0,
"start": "XXXX",
"duration": "XXXX",
"meta": {
"_dd.origin": "lambda",
"cold_start": "false",
"function_arn": "arn:aws:lambda:eu-west-1:XXXX:eu-west-1-tests-python-XXXX-async-metrics_python310",
"function_version": "$LATEST",
"request_id": "XXXX",
"resource_names": "integration-tests-python-XXXX-async-metrics_python310",
"functionname": "integration-tests-python-XXXX-async-metrics_python310",
"datadog_lambda": "X.X.X",
"dd_trace": "X.X.X",
"span.name": "aws.lambda",
"function_trigger.event_source": "dynamodb",
"function_trigger.event_source_arn": "XXXX",
"_dd.base_service": "integration-tests-python"
},
"metrics": {
"_dd.top_level": 1
},
"type": "serverless",
"type": "web",
"span_links": [
{
"trace_id": "XXXX",
Expand Down Expand Up @@ -313,6 +283,36 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
}
]
},
{
"trace_id": "XXXX",
"parent_id": "XXXX",
"span_id": "XXXX",
"service": "aws.lambda",
"resource": "integration-tests-python-XXXX-async-metrics_python310",
"name": "aws.lambda",
"error": 0,
"start": "XXXX",
"duration": "XXXX",
"meta": {
"_dd.origin": "lambda",
"cold_start": "false",
"function_arn": "arn:aws:lambda:eu-west-1:XXXX:eu-west-1-tests-python-XXXX-async-metrics_python310",
"function_version": "$LATEST",
"request_id": "XXXX",
"resource_names": "integration-tests-python-XXXX-async-metrics_python310",
"functionname": "integration-tests-python-XXXX-async-metrics_python310",
"datadog_lambda": "X.X.X",
"dd_trace": "X.X.X",
"span.name": "aws.lambda",
"function_trigger.event_source": "dynamodb",
"function_trigger.event_source_arn": "XXXX",
"_dd.base_service": "integration-tests-python"
},
"metrics": {
"_dd.top_level": 1
},
"type": "serverless"
},
{
"trace_id": "XXXX",
"parent_id": "XXXX",
Expand Down Expand Up @@ -944,7 +944,19 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"_dd.top_level": 1,
"_sampling_priority_v1": 1
},
"type": "web"
"type": "web",
"span_links": [
{
"trace_id": "XXXX",
"span_id": "XXXX",
"attributes": {
"ptr.kind": "aws.s3.object",
"ptr.dir": "u",
"ptr.hash": "1dc3e5d00dae48c1f07d95371a747788",
"link.kind": "span-pointer"
}
}
]
},
{
"trace_id": "XXXX",
Expand Down Expand Up @@ -974,19 +986,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"metrics": {
"_dd.top_level": 1
},
"type": "serverless",
"span_links": [
{
"trace_id": "XXXX",
"span_id": "XXXX",
"attributes": {
"ptr.kind": "aws.s3.object",
"ptr.dir": "u",
"ptr.hash": "1dc3e5d00dae48c1f07d95371a747788",
"link.kind": "span-pointer"
}
}
]
"type": "serverless"
},
{
"trace_id": "XXXX",
Expand Down
90 changes: 45 additions & 45 deletions tests/integration/snapshots/logs/async-metrics_python311.log
Original file line number Diff line number Diff line change
Expand Up @@ -249,37 +249,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"_dd.top_level": 1,
"_sampling_priority_v1": 1
},
"type": "web"
},
{
"trace_id": "XXXX",
"parent_id": "XXXX",
"span_id": "XXXX",
"service": "aws.lambda",
"resource": "integration-tests-python-XXXX-async-metrics_python311",
"name": "aws.lambda",
"error": 0,
"start": "XXXX",
"duration": "XXXX",
"meta": {
"_dd.origin": "lambda",
"cold_start": "false",
"function_arn": "arn:aws:lambda:eu-west-1:XXXX:eu-west-1-tests-python-XXXX-async-metrics_python311",
"function_version": "$LATEST",
"request_id": "XXXX",
"resource_names": "integration-tests-python-XXXX-async-metrics_python311",
"functionname": "integration-tests-python-XXXX-async-metrics_python311",
"datadog_lambda": "X.X.X",
"dd_trace": "X.X.X",
"span.name": "aws.lambda",
"function_trigger.event_source": "dynamodb",
"function_trigger.event_source_arn": "XXXX",
"_dd.base_service": "integration-tests-python"
},
"metrics": {
"_dd.top_level": 1
},
"type": "serverless",
"type": "web",
"span_links": [
{
"trace_id": "XXXX",
Expand Down Expand Up @@ -313,6 +283,36 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
}
]
},
{
"trace_id": "XXXX",
"parent_id": "XXXX",
"span_id": "XXXX",
"service": "aws.lambda",
"resource": "integration-tests-python-XXXX-async-metrics_python311",
"name": "aws.lambda",
"error": 0,
"start": "XXXX",
"duration": "XXXX",
"meta": {
"_dd.origin": "lambda",
"cold_start": "false",
"function_arn": "arn:aws:lambda:eu-west-1:XXXX:eu-west-1-tests-python-XXXX-async-metrics_python311",
"function_version": "$LATEST",
"request_id": "XXXX",
"resource_names": "integration-tests-python-XXXX-async-metrics_python311",
"functionname": "integration-tests-python-XXXX-async-metrics_python311",
"datadog_lambda": "X.X.X",
"dd_trace": "X.X.X",
"span.name": "aws.lambda",
"function_trigger.event_source": "dynamodb",
"function_trigger.event_source_arn": "XXXX",
"_dd.base_service": "integration-tests-python"
},
"metrics": {
"_dd.top_level": 1
},
"type": "serverless"
},
{
"trace_id": "XXXX",
"parent_id": "XXXX",
Expand Down Expand Up @@ -944,7 +944,19 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"_dd.top_level": 1,
"_sampling_priority_v1": 1
},
"type": "web"
"type": "web",
"span_links": [
{
"trace_id": "XXXX",
"span_id": "XXXX",
"attributes": {
"ptr.kind": "aws.s3.object",
"ptr.dir": "u",
"ptr.hash": "1dc3e5d00dae48c1f07d95371a747788",
"link.kind": "span-pointer"
}
}
]
},
{
"trace_id": "XXXX",
Expand Down Expand Up @@ -974,19 +986,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"metrics": {
"_dd.top_level": 1
},
"type": "serverless",
"span_links": [
{
"trace_id": "XXXX",
"span_id": "XXXX",
"attributes": {
"ptr.kind": "aws.s3.object",
"ptr.dir": "u",
"ptr.hash": "1dc3e5d00dae48c1f07d95371a747788",
"link.kind": "span-pointer"
}
}
]
"type": "serverless"
},
{
"trace_id": "XXXX",
Expand Down
90 changes: 45 additions & 45 deletions tests/integration/snapshots/logs/async-metrics_python312.log
Original file line number Diff line number Diff line change
Expand Up @@ -249,37 +249,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"_dd.top_level": 1,
"_sampling_priority_v1": 1
},
"type": "web"
},
{
"trace_id": "XXXX",
"parent_id": "XXXX",
"span_id": "XXXX",
"service": "aws.lambda",
"resource": "integration-tests-python-XXXX-async-metrics_python312",
"name": "aws.lambda",
"error": 0,
"start": "XXXX",
"duration": "XXXX",
"meta": {
"_dd.origin": "lambda",
"cold_start": "false",
"function_arn": "arn:aws:lambda:eu-west-1:XXXX:eu-west-1-tests-python-XXXX-async-metrics_python312",
"function_version": "$LATEST",
"request_id": "XXXX",
"resource_names": "integration-tests-python-XXXX-async-metrics_python312",
"functionname": "integration-tests-python-XXXX-async-metrics_python312",
"datadog_lambda": "X.X.X",
"dd_trace": "X.X.X",
"span.name": "aws.lambda",
"function_trigger.event_source": "dynamodb",
"function_trigger.event_source_arn": "XXXX",
"_dd.base_service": "integration-tests-python"
},
"metrics": {
"_dd.top_level": 1
},
"type": "serverless",
"type": "web",
"span_links": [
{
"trace_id": "XXXX",
Expand Down Expand Up @@ -313,6 +283,36 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
}
]
},
{
"trace_id": "XXXX",
"parent_id": "XXXX",
"span_id": "XXXX",
"service": "aws.lambda",
"resource": "integration-tests-python-XXXX-async-metrics_python312",
"name": "aws.lambda",
"error": 0,
"start": "XXXX",
"duration": "XXXX",
"meta": {
"_dd.origin": "lambda",
"cold_start": "false",
"function_arn": "arn:aws:lambda:eu-west-1:XXXX:eu-west-1-tests-python-XXXX-async-metrics_python312",
"function_version": "$LATEST",
"request_id": "XXXX",
"resource_names": "integration-tests-python-XXXX-async-metrics_python312",
"functionname": "integration-tests-python-XXXX-async-metrics_python312",
"datadog_lambda": "X.X.X",
"dd_trace": "X.X.X",
"span.name": "aws.lambda",
"function_trigger.event_source": "dynamodb",
"function_trigger.event_source_arn": "XXXX",
"_dd.base_service": "integration-tests-python"
},
"metrics": {
"_dd.top_level": 1
},
"type": "serverless"
},
{
"trace_id": "XXXX",
"parent_id": "XXXX",
Expand Down Expand Up @@ -944,7 +944,19 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"_dd.top_level": 1,
"_sampling_priority_v1": 1
},
"type": "web"
"type": "web",
"span_links": [
{
"trace_id": "XXXX",
"span_id": "XXXX",
"attributes": {
"ptr.kind": "aws.s3.object",
"ptr.dir": "u",
"ptr.hash": "1dc3e5d00dae48c1f07d95371a747788",
"link.kind": "span-pointer"
}
}
]
},
{
"trace_id": "XXXX",
Expand Down Expand Up @@ -974,19 +986,7 @@ HTTP GET https://www.datadoghq.com/ Headers: ["Accept-Encoding:gzip, deflate","A
"metrics": {
"_dd.top_level": 1
},
"type": "serverless",
"span_links": [
{
"trace_id": "XXXX",
"span_id": "XXXX",
"attributes": {
"ptr.kind": "aws.s3.object",
"ptr.dir": "u",
"ptr.hash": "1dc3e5d00dae48c1f07d95371a747788",
"link.kind": "span-pointer"
}
}
]
"type": "serverless"
},
{
"trace_id": "XXXX",
Expand Down
Loading
Loading