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

Added dynamodb instrumenter for aws v1_11 sdk #12756

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

akats7
Copy link
Contributor

@akats7 akats7 commented Nov 20, 2024

Resolves #12493

Added a dynamo instrumenter for the aws v1_11 sdk. The most important thing this provides is the db.system attribute which was previously missing and is required according to the sem conv for dynamo. Table name has also been added as an attribute, the instrumenter can continue to be enhanced to add additional 'recommended' attributed from the semantic conventions.

@akats7 akats7 requested a review from a team as a code owner November 20, 2024 07:10
Copy link

linux-foundation-easycla bot commented Nov 20, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link
Contributor

@steverao steverao left a comment

Choose a reason for hiding this comment

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

There are some CI failings, you can refer to related contribution docs to fix them:

@akats7
Copy link
Contributor Author

akats7 commented Nov 21, 2024

The tests were recently rewritten so I need to update them

@akats7
Copy link
Contributor Author

akats7 commented Nov 21, 2024

Hey @steverao @trask, all build issues have been resolved, thanks.

Comment on lines +46 to +48
equalTo(stringKey("aws.table.name"), "sometable"),
equalTo(stringKey("db.system"), "dynamodb"),
equalTo(stringArrayKey("aws.dynamodb.table_names"), singletonList("sometable")));
Copy link
Member

Choose a reason for hiding this comment

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

it's a bit confusing to have both aws.dynamodb.table_names and aws.table.name at the same time, but I don't have a better idea (and aws.table.name requires experimental flag to get anyways)

Copy link
Contributor Author

@akats7 akats7 Nov 23, 2024

Choose a reason for hiding this comment

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

Yep I had the same qualm but I don't want to introduce a breaking change and also wanted to align to the sem convs

@trask trask added this to the v2.11.0 milestone Nov 23, 2024
Comment on lines +30 to +32
String tableName = RequestAccess.getTableName(request.getOriginalRequest());
AttributesExtractorUtil.internalSet(
attributes, AWS_DYNAMODB_TABLE_NAMES, Collections.singletonList(tableName));
Copy link
Member

Choose a reason for hiding this comment

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

this is just an observation more than a request for a change - I understand that this attribute is a List<String> based on the spec, but it doesn't look like this code supports multiple table names, so it feels a little strange for it be defined that way

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah we can likely make an additional enhancement that creates a Request Accessor for the methods that are tied to table names for the batch functions, and then add that Request Accessor to the logic for setting the value. Right now getTable is tied to getTableName which will always return one.

Comment on lines +34 to +36
private static final String SEND_MESSAGE_REQUEST =
"com.amazonaws.services.sqs.model.SendMessageRequest";
private static final String DYNAMODBV2 = "com.amazonaws.services.dynamodbv2.model.";
Copy link
Member

Choose a reason for hiding this comment

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

slight nitpick: perhaps the usage of these variables provides enough context, but it might be a little more intuitive if the names indicated that they reference the names of classes

Suggested change
private static final String SEND_MESSAGE_REQUEST =
"com.amazonaws.services.sqs.model.SendMessageRequest";
private static final String DYNAMODBV2 = "com.amazonaws.services.dynamodbv2.model.";
private static final String SEND_MESSAGE_REQUEST_CLASS =
"com.amazonaws.services.sqs.model.SendMessageRequest";
private static final String DYNAMODBV2_CLASS = "com.amazonaws.services.dynamodbv2.model.";


public class DynamoDbAttributesExtractor implements AttributesExtractor<Request<?>, Response<?>> {

private static final AttributeKey<String> DB_SYSTEM = AttributeKey.stringKey("db.system");
Copy link
Contributor

Choose a reason for hiding this comment

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

usually we add a comment about where this value was copied from like in

// copied from FaasIncubatingAttributes
private static final AttributeKey<String> FAAS_TRIGGER = AttributeKey.stringKey("faas.trigger");
// copied from FaasIncubatingAttributes.FaasTriggerValues
private static final String HTTP = "http";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case being the spec?

Copy link
Contributor

Choose a reason for hiding this comment

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

here it would be // copied from DbIncubatingAttributes

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 this pull request may close these issues.

Instrumentation for AWS SDK 1.11 not setting db.system for DynamoDB requests
5 participants