jackye1995 commented on a change in pull request #4050: URL: https://github.com/apache/iceberg/pull/4050#discussion_r806254981
########## File path: api/src/main/java/org/apache/iceberg/metrics/MetricsContext.java ########## @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iceberg.metrics; + +import java.io.Serializable; +import java.util.Map; +import java.util.Optional; + +/** + * Generalized interface for creating telemetry related instances for tracking + * operations. Implementations must take into account usage considerations + * like thread safety and serialization. + */ +public interface MetricsContext extends Serializable { Review comment: We should be careful about naming here, we already have a class called `Metrics` for column stats. Is it possible for us to have a somewhat different name? ########## File path: api/src/main/java/org/apache/iceberg/io/FileIOMetricsContext.java ########## @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iceberg.io; + +import org.apache.iceberg.metrics.MetricsContext; + +/** + * Extension of MetricsContext for use with FileIO to define standard metrics + * that should be reported. + */ +public interface FileIOMetricsContext extends MetricsContext { Review comment: I think the intention is to have `HadoopFIleIOMetricsContext` accessing these, but we are still switching across different metrics in the implementation and we do not allow unsupported ones. In that case, does it make more sense to just have methods for updating each metrics directly? ########## File path: aws/src/main/java/org/apache/iceberg/aws/s3/S3FileIO.java ########## @@ -104,8 +112,23 @@ private S3Client client() { @Override public void initialize(Map<String, String> properties) { this.awsProperties = new AwsProperties(properties); - this.awsClientFactory = AwsClientFactories.from(properties); - this.s3 = awsClientFactory::s3; + + // Do not override s3 client if it was provided + if (s3 == null) { + this.s3 = AwsClientFactories.from(properties)::s3; + } + + // Report Hadoop metrics if Hadoop is available + try { + Class<? extends MetricsContext> clazz = DynClasses.builder().impl(DEFAULT_METRICS_IMPL).buildChecked(); + + this.metrics = clazz.getDeclaredConstructor().newInstance(); + metrics.initialize(ImmutableMap.of("fileio.scheme", "s3")); Review comment: I think scheme might need to be configurable, because we know people are using S3FileIO also for non-S3 platforms and have different file schemes. ########## File path: api/src/main/java/org/apache/iceberg/io/FileIOMetricsContext.java ########## @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iceberg.io; + +import org.apache.iceberg.metrics.MetricsContext; + +/** + * Extension of MetricsContext for use with FileIO to define standard metrics + * that should be reported. + */ +public interface FileIOMetricsContext extends MetricsContext { Review comment: I think the intention is to have `HadoopFIleIOMetricsContext` accessing these, but we are still switching across different metric names in the implementation and we do not allow unsupported ones. In that case, does it make more sense to just have methods for updating each metrics directly? ########## File path: api/src/main/java/org/apache/iceberg/io/FileIOMetricsContext.java ########## @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iceberg.io; + +import org.apache.iceberg.metrics.MetricsContext; + +/** + * Extension of MetricsContext for use with FileIO to define standard metrics + * that should be reported. + */ +public interface FileIOMetricsContext extends MetricsContext { Review comment: I think the intention is to have `HadoopFIleIOMetricsContext` accessing these, but we are still switching across different metric names in the implementation and we do not allow unsupported ones. In that case, does it make more sense to just have methods for updating each metrics directly? something like ``` public interface FileIOMetricsContext extends MetricsContext { void readBytes(long bytes); } ``` ########## File path: api/src/main/java/org/apache/iceberg/io/FileIOMetricsContext.java ########## @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iceberg.io; + +import org.apache.iceberg.metrics.MetricsContext; + +/** + * Extension of MetricsContext for use with FileIO to define standard metrics + * that should be reported. + */ +public interface FileIOMetricsContext extends MetricsContext { Review comment: I think the intention is to have `HadoopFIleIOMetricsContext` accessing these, but we are still switching across different metric names in the implementation and we do not allow unsupported ones. In that case, does it make more sense to just have methods for updating each metrics directly? something like ``` public interface FileIOMetricsContext extends MetricsContext { void incrementReadBytes(long bytes); } ``` -- 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]
