Skip to content

Add MetricPublisher support to the S3 CRT-based async client - #7500

Open
jencymaryjoseph wants to merge 8 commits into
masterfrom
feature/master/S3CRTMetricPublisher
Open

jencymaryjoseph wants to merge 8 commits into
masterfrom
feature/master/S3CRTMetricPublisher

Conversation

@jencymaryjoseph

Copy link
Copy Markdown
Contributor

Motivation and Context

The S3 CRT-based async client does not currently support SDK metric publication at the client or request level. Applications using existing or custom MetricPublisher implementations therefore cannot retain the same observability when adopting S3AsyncClient.crtBuilder().

This change converts CRT per-request telemetry into the standard ApiCall → ApiCallAttempt → HttpClient metric hierarchy. Each underlying HTTP attempt, including multipart subrequests and retries, produces a separate metric collection.

CRT delivers telemetry on native event-loop threads. Calling customer publisher code directly from those callbacks allowed a slow publisher to delay other CRT work. Metric publication is therefore handed off to a bounded, client-scoped dispatcher.

Modifications

  • Added metricPublishers(Collection<MetricPublisher>) and addMetricPublisher(MetricPublisher) to S3CrtAsyncClientBuilder.
  • Added support for request-level metric publishers configured through request override configuration.
  • Preserved the standard precedence behavior: non-empty request-level publishers replace client-level publishers for that request.
  • Propagated request-level publishers to the internal requests created for multipart copy operations.
  • Converted available CRT telemetry into standard SDK metric collections.
  • Added a client-scoped dispatcher with:
    • One lazily started daemon worker.
    • A bounded 128-entry queue.
    • Non-blocking queue admission.
    • Best-effort delivery when the queue is full.
    • Debug logging for publisher failures and dropped collections.
  • Added bounded shutdown behavior:
    • Collections already accepted when client shutdown begins are flushed for up to five seconds.
    • Metrics produced during native CRT shutdown are drained asynchronously.
    • Customer-provided publishers remain caller-owned and are never closed by the S3 client.
  • Added unit, WireMock, and real-service integration coverage for metric mapping, publisher precedence, multipart operations, failures, queue saturation, and shutdown.

Only metrics available through current CRT telemetry are populated. Differences from the standard S3 client are documented in the developer guide.

Testing

  • Ran the targeted S3 CRT client, response-handler, dispatcher, copy, and WireMock test suites.
    • 132 tests passed with no failures.
  • Successfully completed the 60-module S3 reactor package build.
  • S3 Checkstyle completed with zero violations.
  • Added integration coverage for:
    • Small and multipart GetObject
    • PutObject
    • Failed requests
    • Client- and request-level publisher resolution
    • Multipart copy and tagging subrequests
  • Ran focused performance benchmarks covering normal publishers, synthetic blocking publishers, queue saturation, drops, allocation, and shutdown. Normal publishers showed no repeatable end-to-end regression, while asynchronous dispatch prevented blocking publishers from occupying CRT event-loop threads.

Screenshots

N/A

Types of changes

  • Bug fix
  • New feature

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 Javadoc update.
  • I have updated the Javadoc accordingly.
  • I have added tests to cover my changes.
  • All targeted tests passed.
  • I have added a changelog entry.
  • My change implements a 1.11 parity feature.

License

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

* add client-level MetricPublisher support to the S3 CRT client

* address review feedback
* add request-level MetricPublisher support to the S3 CRT client

* drop @SdkTestInternalApi from CRT request-level metric helpers

* refactor : stash request-level publishers once for copyObject instead of a per-sub-request wrapper

* address review comments
…TMetricPublisher

# Conflicts:
#	services/s3/src/main/java/software/amazon/awssdk/services/s3/internal/crt/DefaultS3CrtAsyncClient.java
#	services/s3/src/main/java/software/amazon/awssdk/services/s3/internal/crt/S3CrtAsyncHttpClient.java
#	services/s3/src/main/java/software/amazon/awssdk/services/s3/internal/crt/S3CrtResponseHandlerAdapter.java
#	services/s3/src/test/java/software/amazon/awssdk/services/s3/internal/crt/S3CrtClientWiremockTest.java
* Publish additional S3 CRT request metrics

* Use builder for S3 CRT response handler adapter
* Isolate S3 CRT metric publishers from event loop

* Use debug logging for S3 CRT metric publishing

* Address S3 CRT metric dispatcher review feedback

* Address S3 CRT metric dispatcher review comments
@jencymaryjoseph jencymaryjoseph added the api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team label Oct 30, 2026
@jencymaryjoseph
jencymaryjoseph requested a review from a team as a code owner October 30, 2026 23:32

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant