Skip to content

Conversation

@SylvainJuge
Copy link
Member

@SylvainJuge SylvainJuge commented May 4, 2023

What does this PR do?

Fixes #3006

Captures the following as OTel attributes from OTel semantic conventions for S3.

  • aws.s3.bucket
  • aws.s3.key
  • aws.s3.copy_source

The following attributes are not covered

  • aws.s3.upload_id
  • aws.s3.delete
  • aws.s3.part_number

This PR is quite large due to test refactoring.

Checklist

  • This is an enhancement of existing features, or a new feature in existing plugins
    • I have updated CHANGELOG.asciidoc
    • I have added tests that prove my fix is effective or that my feature works
    • Added an API method or config option? Document in which version this will be introduced n/a
    • I have made corresponding changes to the documentation n/a

@Nullable
@Override
protected String getObjectKey(Request<?> request, @Nullable String bucketName) {
Copy link
Member Author

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.

Comment on lines +77 to +91
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();
Copy link
Member Author

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)
Copy link
Member Author

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.

Comment on lines +42 to +58
@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);
}
Copy link
Member Author

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.

@ghost
Copy link

ghost commented May 4, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview previewSnapshots

Expand to view the summary

Build stats

  • Start Time: 2023-05-05T12:30:08.261+0000

  • Duration: 15 min 26 sec

❕ Flaky test report

No test was executed to be analysed.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • run benchmark tests : Run the benchmark tests.

  • run jdk compatibility tests : Run the JDK Compatibility tests.

  • run integration tests : Run the Agent Integration tests.

  • run end-to-end tests : Run the APM-ITs.

  • run windows tests : Build & tests on windows.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@SylvainJuge SylvainJuge marked this pull request as ready for review May 4, 2023 14:52
@github-actions
Copy link

github-actions bot commented May 4, 2023

/test

@SylvainJuge SylvainJuge requested a review from a team May 4, 2023 14:58
@SylvainJuge SylvainJuge merged commit 2d9f8cd into elastic:main May 5, 2023
@SylvainJuge SylvainJuge deleted the s3-bucket-otel-attributes branch May 5, 2023 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants