Skip to content

Conversation

@zoewangg
Copy link
Contributor

Motivation and Context

Add WRITE_THROUGHPUT metric to measure request body upload speed (bytes/sec) for sync clients.

This metric helps customers understand upload performance and diagnose throughput issues. The implementation uses tracking last read time which provides more accurate throughput measurement than TTFB-based approaches, especially on fast networks where server processing time can significantly skew results.

Note: This PR targets the feature branch. Async client support will be added in a follow-up PR to the same feature branch,
and the feature branch will be merged to master after both sync and async implementations are complete.

Modifications

  • CoreMetric.java - Added WRITE_THROUGHPUT metric with comprehensive Javadoc explaining formula, exclusions, and buffering caveat
  • SdkInternalExecutionAttribute.java - Added REQUEST_BYTES_WRITTEN, REQUEST_BODY_FIRST_BYTE_WRITTEN_NANO_TIME,
    REQUEST_BODY_LAST_BYTE_WRITTEN_NANO_TIME
  • BytesWrittenTrackingInputStream.java - New class that tracks bytes written and timing (follows BytesReadTrackingInputStream pattern)
  • ApiCallAttemptMetricCollectionStage.java - Initializes tracking counters before each attempt
  • MakeHttpRequestStage.java - Combined trackBytesWritten and enforceContentLengthIfPresent into single wrapRequestContentStream method to wrap
    stream once
  • HandleResponseStage.java - Reports WRITE_THROUGHPUT metric in new reportWriteThroughput method
  • MetricUtils.java - Added helper methods for accessing write metric attributes

Formula: WRITE_THROUGHPUT = RequestBytesWritten / (LastByteWrittenTime - FirstByteWrittenTime)

Testing

  • Unit tests: BytesWrittenTrackingInputStreamTest - 11 tests covering all read methods, edge cases, and timing behavior
  • Functional tests: SyncWriteThroughputMetricTest - WireMock-based JUnit 5 tests verifying metric is reported for requests with body and not
    reported for requests without body
  • Integration test: PutObjectIntegrationTest.putObject_withRequestBody_reportsWriteThroughputMetric - Validates real S3 upload reports the metric

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](https://github.com/aws/aws-sdk-java-v2/blob/master/docs/
    LaunchChangelog.md)

License

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

@zoewangg zoewangg requested a review from a team as a code owner January 24, 2026 00:15
@sonarqubecloud
Copy link

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.

1 participant