Skip to content

Commit

Permalink
[mq] working branch - merge bf0dcb6 on top of main at 122caa6
Browse files Browse the repository at this point in the history
{"baseBranch":"main","baseCommit":"122caa61c278a75100d7c23fc601588cc0c60308","createdAt":"2025-02-08T00:23:07.230758Z","headSha":"bf0dcb6593b80dd1c786be40b7769963ca220b44","id":"295fe83e-eaf4-4ea5-a3f3-1bb081821dfd","priority":"200","pullRequestNumber":"12180","queuedAt":"2025-02-08T00:23:07.230065Z","status":"STATUS_QUEUED"}
  • Loading branch information
dd-mergequeue[bot] authored Feb 8, 2025
2 parents 2ea7508 + bf0dcb6 commit 3efc9f6
Show file tree
Hide file tree
Showing 4 changed files with 335 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ddtrace/contrib/internal/botocore/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ def _load_dynamodb_primary_key_names_for_tables() -> Dict[str, Set[str]]:
os.getenv("DD_TRACE_CLOUD_PAYLOAD_TAGGING_MAX_TAGS", 758)
), # RFC defined default limit - spans are limited past 1000
"payload_tagging_services": set(
os.getenv("DD_TRACE_CLOUD_PAYLOAD_TAGGING_SERVICES", default={"s3", "sns", "sqs", "kinesis", "eventbridge"})
service.strip()
for service in os.getenv("DD_TRACE_CLOUD_PAYLOAD_TAGGING_SERVICES", "s3,sns,sqs,kinesis,eventbridge").split(
","
)
),
},
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fixes:
- |
configurations: This fix resolves an issue where DD_TRACE_CLOUD_PAYLOAD_TAGGING_SERVICES env variable was not parsed correctly
52 changes: 52 additions & 0 deletions tests/contrib/botocore/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"meta.aws.response.body.HTTPHeaders.content-length",
"meta.aws.response.body.HTTPHeaders.x-amzn-requestid",
"meta.error.stack",
"meta.aws.response.body.HTTPHeaders.x-amz-crc32",
]


Expand Down Expand Up @@ -4093,6 +4094,57 @@ def test_aws_payload_tagging_s3_invalid_config(self):
with pytest.raises(Exception):
s3.list_objects(bucket="mybucket")

@pytest.mark.snapshot(ignores=snapshot_ignores)
@pytest.mark.skipif(
PYTHON_VERSION_INFO < (3, 8),
reason="Skipping for older py versions whose latest supported moto versions don't have the right dynamodb api",
)
@mock_dynamodb
def test_dynamodb_payload_tagging(self):
with self.override_config(
"botocore",
dict(payload_tagging_request="all", payload_tagging_response="all", payload_tagging_services="s3,dynamodb"),
):
ddb = self.session.create_client("dynamodb", region_name="us-west-2")
pin = Pin(service=self.TEST_SERVICE)
pin._tracer = self.tracer
pin.onto(ddb)

with self.override_config("botocore", dict(instrument_internals=True)):
ddb.create_table(
TableName="foobar",
AttributeDefinitions=[{"AttributeName": "myattr", "AttributeType": "S"}],
KeySchema=[{"AttributeName": "myattr", "KeyType": "HASH"}],
BillingMode="PAY_PER_REQUEST",
)
ddb.put_item(TableName="foobar", Item={"myattr": {"S": "baz"}})
ddb.get_item(TableName="foobar", Key={"myattr": {"S": "baz"}})

spans = self.get_spans()
assert spans
span = spans[0]
assert len(spans) == 6
assert_is_measured(span)
assert span.get_tag("aws.operation") == "CreateTable"
assert span.get_tag("component") == "botocore"
assert span.get_tag("span.kind"), "client"
assert_span_http_status_code(span, 200)
assert span.service == "test-botocore-tracing.dynamodb"
assert span.resource == "dynamodb.createtable"

span = spans[1]
assert span.name == "botocore.parsers.parse"
assert span.get_tag("component") == "botocore"
assert span.get_tag("span.kind"), "client"
assert span.service == "test-botocore-tracing.dynamodb"
assert span.resource == "botocore.parsers.parse"

span = spans[2]
assert span.get_tag("aws.operation") == "PutItem"
# Since the dynamodb_primary_key_names_for_tables isn't configured, we
# cannot create span pointers for this item.
assert not span._links

@pytest.mark.skip(reason="broken during period of skipping on main branch")
@pytest.mark.snapshot(ignores=snapshot_ignores)
@mock_s3
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
[[
{
"name": "dynamodb.command",
"service": "test-botocore-tracing.dynamodb",
"resource": "dynamodb.getitem",
"trace_id": 0,
"span_id": 1,
"parent_id": 0,
"type": "http",
"error": 0,
"meta": {
"_dd.base_service": "tests.contrib.botocore",
"_dd.p.dm": "-0",
"_dd.p.tid": "67a6776f00000000",
"aws.agent": "botocore",
"aws.dynamodb.table_name": "foobar",
"aws.operation": "GetItem",
"aws.region": "us-west-2",
"aws.request.body.Key.myattr.S": "baz",
"aws.request.body.TableName": "foobar",
"aws.requestid": "1pGBOmkOZ1BdOWIHeWnkX96CO0n93XaZSqtfcgRZJhe6hrREgPCs",
"aws.response.body.HTTPHeaders.date": "Fri, 07 Feb 2025 21:13:20 GMT",
"aws.response.body.HTTPHeaders.server": "amazon.com",
"aws.response.body.HTTPHeaders.x-amz-crc32": "357125523",
"aws.response.body.HTTPHeaders.x-amzn-requestid": "1pGBOmkOZ1BdOWIHeWnkX96CO0n93XaZSqtfcgRZJhe6hrREgPCs",
"aws.response.body.HTTPStatusCode": "200",
"aws.response.body.RequestId": "1pGBOmkOZ1BdOWIHeWnkX96CO0n93XaZSqtfcgRZJhe6hrREgPCs",
"aws.response.body.RetryAttempts": "0",
"aws_service": "dynamodb",
"component": "botocore",
"http.status_code": "200",
"language": "python",
"region": "us-west-2",
"runtime-id": "ef4281e602a34aa3b78873db2aa0da91",
"span.kind": "client",
"tablename": "foobar"
},
"metrics": {
"_dd.measured": 1,
"_dd.top_level": 1,
"_dd.tracer_kr": 1.0,
"_sampling_priority_v1": 1,
"process_id": 7842,
"retry_attempts": 0
},
"duration": 898096696,
"start": 1738962799557241364
},
{
"name": "botocore.parsers.parse",
"service": "test-botocore-tracing.dynamodb",
"resource": "botocore.parsers.parse",
"trace_id": 0,
"span_id": 2,
"parent_id": 1,
"type": "",
"error": 0,
"meta": {
"_dd.base_service": "tests.contrib.botocore",
"component": "botocore",
"span.kind": "client"
},
"duration": 328440,
"start": 1738962800007520310
}],
[
{
"name": "dynamodb.command",
"service": "test-botocore-tracing.dynamodb",
"resource": "dynamodb.createtable",
"trace_id": 1,
"span_id": 1,
"parent_id": 0,
"type": "http",
"error": 0,
"meta": {
"_dd.base_service": "tests.contrib.botocore",
"_dd.p.dm": "-0",
"_dd.p.tid": "67a6776d00000000",
"aws.agent": "botocore",
"aws.dynamodb.table_name": "foobar",
"aws.operation": "CreateTable",
"aws.region": "us-west-2",
"aws.request.body.AttributeDefinitions.0.AttributeName": "myattr",
"aws.request.body.AttributeDefinitions.0.AttributeType": "S",
"aws.request.body.BillingMode": "PAY_PER_REQUEST",
"aws.request.body.KeySchema.0.AttributeName": "myattr",
"aws.request.body.KeySchema.0.KeyType": "HASH",
"aws.request.body.TableName": "foobar",
"aws.requestid": "s5qfbhhfkr4Go9yZWDL5eSDNflqO9AY7R1PtdbeHgZSnABZRXWwc",
"aws.response.body.HTTPHeaders.date": "Fri, 07 Feb 2025 21:13:17 GMT",
"aws.response.body.HTTPHeaders.server": "amazon.com",
"aws.response.body.HTTPHeaders.x-amz-crc32": "725802381",
"aws.response.body.HTTPHeaders.x-amzn-requestid": "s5qfbhhfkr4Go9yZWDL5eSDNflqO9AY7R1PtdbeHgZSnABZRXWwc",
"aws.response.body.HTTPStatusCode": "200",
"aws.response.body.RequestId": "s5qfbhhfkr4Go9yZWDL5eSDNflqO9AY7R1PtdbeHgZSnABZRXWwc",
"aws.response.body.RetryAttempts": "0",
"aws_service": "dynamodb",
"component": "botocore",
"http.status_code": "200",
"language": "python",
"region": "us-west-2",
"runtime-id": "ef4281e602a34aa3b78873db2aa0da91",
"span.kind": "client",
"tablename": "foobar"
},
"metrics": {
"_dd.measured": 1,
"_dd.top_level": 1,
"_dd.tracer_kr": 1.0,
"_sampling_priority_v1": 1,
"process_id": 7842,
"retry_attempts": 0
},
"duration": 1169517214,
"start": 1738962797488686721
},
{
"name": "botocore.parsers.parse",
"service": "test-botocore-tracing.dynamodb",
"resource": "botocore.parsers.parse",
"trace_id": 1,
"span_id": 2,
"parent_id": 1,
"type": "",
"error": 0,
"meta": {
"_dd.base_service": "tests.contrib.botocore",
"component": "botocore",
"span.kind": "client"
},
"duration": 680298,
"start": 1738962798196385705
}],
[
{
"name": "dynamodb.command",
"service": "test-botocore-tracing.dynamodb",
"resource": "dynamodb.putitem",
"trace_id": 2,
"span_id": 1,
"parent_id": 0,
"type": "http",
"error": 0,
"meta": {
"_dd.base_service": "tests.contrib.botocore",
"_dd.p.dm": "-0",
"_dd.p.tid": "67a6776e00000000",
"aws.agent": "botocore",
"aws.dynamodb.table_name": "foobar",
"aws.operation": "PutItem",
"aws.region": "us-west-2",
"aws.request.body.Item.myattr.S": "baz",
"aws.request.body.TableName": "foobar",
"aws.requestid": "l8KoXDDLWxK9lyqrrMRmtbdenA29koyXlCZEOlqgXgh46RkAzTiV",
"aws.response.body.HTTPHeaders.date": "Fri, 07 Feb 2025 21:13:19 GMT",
"aws.response.body.HTTPHeaders.server": "amazon.com",
"aws.response.body.HTTPHeaders.x-amz-crc32": "2745614147",
"aws.response.body.HTTPHeaders.x-amzn-requestid": "l8KoXDDLWxK9lyqrrMRmtbdenA29koyXlCZEOlqgXgh46RkAzTiV",
"aws.response.body.HTTPStatusCode": "200",
"aws.response.body.RequestId": "l8KoXDDLWxK9lyqrrMRmtbdenA29koyXlCZEOlqgXgh46RkAzTiV",
"aws.response.body.RetryAttempts": "0",
"aws_service": "dynamodb",
"component": "botocore",
"http.status_code": "200",
"language": "python",
"region": "us-west-2",
"runtime-id": "ef4281e602a34aa3b78873db2aa0da91",
"span.kind": "client",
"tablename": "foobar"
},
"metrics": {
"_dd.measured": 1,
"_dd.top_level": 1,
"_dd.tracer_kr": 1.0,
"_sampling_priority_v1": 1,
"process_id": 7842,
"retry_attempts": 0
},
"duration": 897531031,
"start": 1738962798659199416
},
{
"name": "botocore.parsers.parse",
"service": "test-botocore-tracing.dynamodb",
"resource": "botocore.parsers.parse",
"trace_id": 2,
"span_id": 2,
"parent_id": 1,
"type": "",
"error": 0,
"meta": {
"_dd.base_service": "tests.contrib.botocore",
"component": "botocore",
"span.kind": "client"
},
"duration": 188248,
"start": 1738962799115125322
}],
[
{
"name": "sqs.command",
"service": "aws.sqs",
"resource": "sqs.listqueues",
"trace_id": 3,
"span_id": 1,
"parent_id": 0,
"type": "http",
"error": 0,
"meta": {
"_dd.base_service": "tests.contrib.botocore",
"_dd.p.dm": "-0",
"_dd.p.tid": "67a6776d00000000",
"aws.agent": "botocore",
"aws.operation": "ListQueues",
"aws.region": "us-east-1",
"aws.requestid": "8BQ748A97HZTB3DQNICVX52K4H4KRCK9BWKBM3QX1FE0F9DJ4481",
"aws_service": "sqs",
"component": "botocore",
"http.status_code": "200",
"language": "python",
"region": "us-east-1",
"runtime-id": "ef4281e602a34aa3b78873db2aa0da91",
"span.kind": "client"
},
"metrics": {
"_dd.measured": 1,
"_dd.top_level": 1,
"_dd.tracer_kr": 1.0,
"_sampling_priority_v1": 1,
"process_id": 7842,
"retry_attempts": 0
},
"duration": 17043485,
"start": 1738962797437241544
}],
[
{
"name": "sqs.command",
"service": "aws.sqs",
"resource": "sqs.createqueue",
"trace_id": 4,
"span_id": 1,
"parent_id": 0,
"type": "http",
"error": 0,
"meta": {
"_dd.base_service": "tests.contrib.botocore",
"_dd.p.dm": "-0",
"_dd.p.tid": "67a6776d00000000",
"aws.agent": "botocore",
"aws.operation": "CreateQueue",
"aws.region": "us-east-1",
"aws.requestid": "P5XR375SOHFTGCNG78FP0M00O7J8TR5Y01KWQXDNSAC2MR17BVSN",
"aws.sqs.queue_name": "Test",
"aws_service": "sqs",
"component": "botocore",
"http.status_code": "200",
"language": "python",
"queuename": "Test",
"region": "us-east-1",
"runtime-id": "ef4281e602a34aa3b78873db2aa0da91",
"span.kind": "client"
},
"metrics": {
"_dd.measured": 1,
"_dd.top_level": 1,
"_dd.tracer_kr": 1.0,
"_sampling_priority_v1": 1,
"process_id": 7842,
"retry_attempts": 0
},
"duration": 9204293,
"start": 1738962797455089485
}]]

0 comments on commit 3efc9f6

Please sign in to comment.