Skip to content

Conversation

S-Saranya1
Copy link
Contributor

@S-Saranya1 S-Saranya1 commented Sep 5, 2025

S3_EXPRESS_BUCKET and S3_ACCESS_GRANTS business metric feature implementation that tracks when an operation called using the S3 Express feature and S3 Access Grants feature.

Motivation and Context

Adding business metrics for feature IDs to track S3 Express (feature ID "J") and S3 Access Grants (feature ID "K") usage in AWS SDK S3 requests. This tracks customer adoption of these S3 features.

Modifications

  • Added S3_EXPRESS_BUCKET("J") and S3_ACCESS_GRANTS("K") to BusinessMetricFeatureId enum

  • Created S3ExpressUserAgentInterceptor that detects when the bucket name matches S3 Express Ruleset and express credentials are used.

  • Created S3AccessGrantsUserAgentInterceptor that detects S3 Access Grants plugin by checking if providerName contains "S3AccessGrantsIdentityProvider"

  • Registered both interceptors in S3's execution.interceptors

  • When S3 Express sessions detected, adds metric "J" to business metrics collection, appearing as "m/J" in User-Agent headers

  • When S3 Access Grants plugin detected, adds metric "K" to business metrics collection, appearing as "m/K" in User-Agent headers

Testing

Added unit tests and integ tests.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@S-Saranya1 S-Saranya1 requested a review from a team as a code owner September 5, 2025 15:11
Copy link

sonarqubecloud bot commented Sep 5, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

* Integration test to verify that S3 Express operations include the correct business metric feature ID
* in the User-Agent header for tracking purposes.
*/
public class S3ExpressUserAgentIntegrationTest extends S3ExpressIntegrationTestBase {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need integ test for this ?
Can we add mocks/stubs for the same test class and move it to Junits to test that request has required user_Agent ?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1, let's add functional tests using wiremock server or mock http client instead.


// Verify the User-Agent contains the S3 Express business metric feature ID
String expectedFeatureId = BusinessMetricFeatureId.S3_EXPRESS_BUCKET.value();
assertThat(userAgent).containsPattern("m/([A-Za-z0-9+\\-]+,)*" + expectedFeatureId + "(,[A-Za-z0-9+\\-]+)*");
Copy link
Contributor

Choose a reason for hiding this comment

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

If we make it as Junit we can assert on deterministic useragen instead of using pattern match , also can we add the final string in verification ?

* Integration test to verify that S3 Access Grants operations include the correct business metric feature ID
* in the User-Agent header for tracking purposes.
*/
public class S3AccessGrantsUserAgentIntegrationTest extends S3IntegrationTestBase {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add Junit and use mock/stubs and verify the request is created with required header ?

*/

@SdkInternalApi
public final class S3ExpressUserAgentInterceptor implements ExecutionInterceptor {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of separate interceptors , can we create a single interceptor say S3BusinessMetricInterceptor add all the business metric for S3 related in one place else we need to do toBuilder which discards older builder instance and creates new builder instances for every call .

* Interceptor that adds business metrics for S3 Access Grants operations.
*/
@SdkInternalApi
public final class S3AccessGrantsUserAgentInterceptor implements ExecutionInterceptor {
Copy link
Contributor

Choose a reason for hiding this comment

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

s3accessgrants comes from.
https://github.com/aws/aws-s3-accessgrants-plugin-java-v2/blob/main/src/main/java/software/amazon/awssdk/s3accessgrants/plugin/S3AccessGrantsIdentityProvider.java ,
why can't we modify this package and pass user agent in S3AccessGrants package ?

Copy link
Contributor

Choose a reason for hiding this comment

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

We are moving away from using execution interceptor for SDK functionalities. Is there a better way to add user agent other than execution interceptor?

if (request instanceof S3Request) {
S3Request s3Request = (S3Request) request;

if (S3ExpressUtils.useS3Express(executionAttributes) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is useS3Express and useS3ExpressAuthScheme is used to determine if its S3Express ?
Also since its used in interceptor how do we make sure executionAttributes are rightly set before this interceptor ?

* Interceptor that adds business metrics for S3 Access Grants operations.
*/
@SdkInternalApi
public final class S3AccessGrantsUserAgentInterceptor implements ExecutionInterceptor {
Copy link
Contributor

Choose a reason for hiding this comment

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

We are moving away from using execution interceptor for SDK functionalities. Is there a better way to add user agent other than execution interceptor?

@@ -0,0 +1,2 @@
software.amazon.awssdk.services.s3.internal.handlers.S3ExpressUserAgentInterceptor
Copy link
Contributor

Choose a reason for hiding this comment

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

We should not use execution.interceptors. See #3550

* Integration test to verify that S3 Express operations include the correct business metric feature ID
* in the User-Agent header for tracking purposes.
*/
public class S3ExpressUserAgentIntegrationTest extends S3ExpressIntegrationTestBase {
Copy link
Contributor

Choose a reason for hiding this comment

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

+1, let's add functional tests using wiremock server or mock http client instead.

@S-Saranya1
Copy link
Contributor Author

Closing this on behalf of #6409. For S3_ACCESS_GRANTS, since it's a plugin and we are not using execution interceptors, we will create a PR with the team here: https://github.com/aws/aws-s3-accessgrants-plugin-java-v2

@S-Saranya1 S-Saranya1 closed this Sep 8, 2025
Copy link

github-actions bot commented Sep 8, 2025

This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2025
@S-Saranya1 S-Saranya1 deleted the somepal/s3-featureID-implementation branch September 8, 2025 20:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants