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

Getting warning message from span_pointers.dynamodb #11320

Open
anna20160606 opened this issue Nov 6, 2024 · 6 comments · May be fixed by #11420
Open

Getting warning message from span_pointers.dynamodb #11320

anna20160606 opened this issue Nov 6, 2024 · 6 comments · May be fixed by #11420
Assignees

Comments

@anna20160606
Copy link

Get warning message, but looks like AWS DB update went through. What kind of error does this message indicates? Assume this exception will not break the existing function?

WARNING [ddtrace._trace.utils_botocore.span_pointers.dynamodb] [dynamodb.py:181] [dd.service=<SERVICE_NAME>.env=prod dd.version= dd.span_id=<SPAN_ID>] - failed to generate DynamoDB.UpdateItem span pointer: primary key value object must have exactly one field: 12, 2 additional messages skipped

Maybe related to this change? b98138c

@harshilprajapati96
Copy link

I am also getting similar issue, I have table with

  • hash_key: PK
  • range _key: SK

and I am getting

failed to generate DynamoDB.PutItem span pointer: primary key field PK must have exactly one value: 10

@apiarian-datadog
Copy link
Contributor

Hello! Thanks for letting us know about this. The span pointer code fails safe, so while these spans won't have span pointers associated with them, the rest of the code should work just fine.

We wrote the logic based on the documentation available to us. Perhaps the underlying boto3 api handling is more flexible than their docs had suggested?

Could you share more about the schema of the table (the primary key in particular) and an example of the boto3 api call you are making? That should help us adjust our parsing logic accordingly.

@apiarian-datadog apiarian-datadog self-assigned this Nov 8, 2024
@harshilprajapati96
Copy link

I have table with

hash_key: PK
range _key: SK

ddtrace.config.botocore["dynamodb_primary_key_names_for_tables"] = {
        f"table_name": {"PK", "SK"},
    }

Here is how I put item

item = {"PK": "something", "SK": "otherthing", "key1": "value1", "key2": "value2" }
client = boto3.resource("dynamodb")
table = client.Table(table_name)
table.put_item(Item=item)

I get

failed to generate DynamoDB.PutItem span pointer: primary key field PK must have exactly one value: 10, 1 additional messages skipped

This also happens when I only have PK no SK.

@apiarian-datadog
Copy link
Contributor

Ah, interesting. Our code currently assumes that the dynamo api is being called with value objects, not values. i.e. {"PK": {"S": "something"}, ... } rather than {"PK": "something", ...}. I couldn't get the latter working with some of the lower level APIs, but perhaps the Table version of put_item does more interesting argument processing. I'll update our code to handle this form as well.

@robotmlg
Copy link

Hi, I just want to report that I'm also experiencing this issue on Table.update_item and Table.delete_item. I see later commits from you for methods (and more), so I just wanted to make sure they're also on your radar for a fix.

the exact code:

table.update_item(
            Key={"id": id},
            ExpressionAttributeNames={"#k": key},
            ExpressionAttributeValues={':inc': amount, ':start': 0, ':id': id},
            ConditionExpression='id = :id',
            UpdateExpression='SET #k = if_not_exists(#k, :start) + :inc'
        )
# log: failed to generate DynamoDB.UpdateItem span pointer: primary key value object must have exactly one field: 8, 1 additional messages skipped

table.delete_item(Key={"id": id, "type": type})
# log: failed to generate DynamoDB.DeleteItem span pointer: primary key value object must have exactly one field: 16

Let me know if you need more details from me.

@apiarian-datadog
Copy link
Contributor

Hi folks, thanks for the feedback!

I think we've got a fix that should cover all of the documented Table resource methods (I've tested it with table.put_item, table.update_item, table.delete_item, as well as table.batch_writer). We also have a patch in progress to make the logging less noisy.

These fixes will probably be out in the next release and we'll backport them to 2.16 as a patch as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants