danielcweeks commented on code in PR #16235:
URL: https://github.com/apache/iceberg/pull/16235#discussion_r3470581476
##########
aws/src/main/java/org/apache/iceberg/aws/s3/S3FileIOProperties.java:
##########
@@ -1197,4 +1209,63 @@ private <T> T loadSdkPluginConfigurations(String impl,
Map<String, String> prope
public Map<String, String> properties() {
return allProperties;
}
+
+ public String metricsPublisherImpl() {
+ return metricsPublisherImpl;
+ }
+
+ /**
+ * Configure a custom {@link MetricPublisher} for an S3 client.
+ *
+ * <p>Sample usage:
+ *
+ * <pre>
+ *
S3Client.builder().applyMutation(s3FileIOProperties::applyMetricsPublisherConfiguration)
+ * </pre>
+ */
+ public <T extends S3BaseClientBuilder<T, ?>> void
applyMetricsPublisherConfiguration(T builder) {
+ if (metricsPublisherImpl != null) {
+ ClientOverrideConfiguration.Builder configBuilder =
+ null != builder.overrideConfiguration()
+ ? builder.overrideConfiguration().toBuilder()
+ : ClientOverrideConfiguration.builder();
+ builder.overrideConfiguration(
+ configBuilder.addMetricPublisher(loadMetricPublisher()).build());
+ }
+ }
+
+ private MetricPublisher loadMetricPublisher() {
+ // Phase 1: look up the factory. A NoSuchMethodException here means the
class does not
+ // declare `create(Map)` — fall back to the no-arg constructor path. Any
OTHER exception
+ // from a factory that DOES exist (e.g. the factory itself throws) should
surface via the
+ // wrapping IllegalArgumentException in phase 2 so users can distinguish
"wrong signature"
+ // from "misconfigured factory".
+ DynMethods.StaticMethod factory = null;
+ try {
+ factory =
+ DynMethods.builder("create")
+ .hiddenImpl(metricsPublisherImpl, Map.class)
+ .buildStaticChecked();
Review Comment:
Why are we expecting a `create(Map)` method to exist here? Looking at the
implementations provided by the SDKv2, two of the three have `create()` (no
params) and none support one with a map of properties.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]