- Notifications
You must be signed in to change notification settings - Fork 327
Capture S3 bucket+key as otel attributes #3136
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
Capture S3 bucket+key as otel attributes #3136
Conversation
| | ||
| @Nullable | ||
| @Override | ||
| protected String getObjectKey(Request<?> request, @Nullable String bucketName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[for reviewer] with SDK v1 we have to use some manual parsing of an HTTP header, this is not the case with v2.
| newTest(() -> dynamoDB.createTable(new CreateTableRequest().withTableName(TABLE_NAME) | ||
| .withAttributeDefinitions(List.of( | ||
| new AttributeDefinition("attributeOne", ScalarAttributeType.S), | ||
| new AttributeDefinition("attributeTwo", ScalarAttributeType.N) | ||
| )) | ||
| .withKeySchema(List.of( | ||
| new KeySchemaElement("attributeOne", KeyType.HASH), | ||
| new KeySchemaElement("attributeTwo", KeyType.RANGE) | ||
| )) | ||
| .withBillingMode(BillingMode.PAY_PER_REQUEST))) | ||
| .operationName("CreateTable") | ||
| .entityName(TABLE_NAME) | ||
| .action("query") | ||
| .withSpanAssertions(dbAssert) | ||
| .execute(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[for reviewer] this is mostly automatic refactoring with a "test builder" that allows to combine assertions on the spans in a more declarative way.
| newTest(() -> s3.createBucket(BUCKET_NAME)) | ||
| .operationName("CreateBucket") | ||
| .entityName(BUCKET_NAME) | ||
| .otelAttribute("aws.s3.bucket", BUCKET_NAME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[for reviewer] this tests the expected OTel attribute capture that was added with this PR.
| @Nullable | ||
| @Override | ||
| protected String getObjectKey(SdkRequest request, @Nullable String bucketName) { | ||
| String value = awsSdkDataSource.getFieldValue(IAwsSdkDataSource.OBJECT_KEY_FIELD, request); | ||
| | ||
| if (value == null) { | ||
| value = awsSdkDataSource.getFieldValue(IAwsSdkDataSource.OBJECT_DESTINATION_KEY_FIELD, request); | ||
| } | ||
| | ||
| return value; | ||
| } | ||
| | ||
| @Nullable | ||
| @Override | ||
| protected String getCopySource(SdkRequest request) { | ||
| return awsSdkDataSource.getFieldValue(IAwsSdkDataSource.COPY_SOURCE_FIELD, request); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[for reviewer] with SDK v2 we don't need to parse anything from the request, just capture it.
| /test |
What does this PR do?
Fixes #3006
Captures the following as OTel attributes from OTel semantic conventions for S3.
aws.s3.bucketaws.s3.keyaws.s3.copy_sourceThe following attributes are not covered
aws.s3.upload_idaws.s3.deleteaws.s3.part_numberThis PR is quite large due to test refactoring.
Checklist
Added an API method or config option? Document in which version this will be introducedn/aI have made corresponding changes to the documentationn/a