Skip to content

Commit

Permalink
Use shared metrics collector in PestoS3ClientFactory
Browse files Browse the repository at this point in the history
Previously, an instance of PrestoS3FileSystemStats instance was
created in PrestoS3ClientFactory which means it would not report
S3 client stats to the instance registered with JMX. This would
only have affected PrestoS3Select clients. Now the same metric
instance is shared with PrestoS3FileSystem
  • Loading branch information
pettyjamesm authored and electrum committed Apr 15, 2020
1 parent e66b802 commit 0e24cb7
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
import com.amazonaws.metrics.RequestMetricCollector;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Builder;
import com.amazonaws.services.s3.AmazonS3Client;
import io.airlift.units.Duration;
import io.prestosql.plugin.hive.HiveConfig;
import io.prestosql.plugin.hive.s3.HiveS3Config;
import io.prestosql.plugin.hive.s3.PrestoS3FileSystem;
import io.prestosql.plugin.hive.s3.PrestoS3FileSystemMetricCollector;
import io.prestosql.plugin.hive.s3.PrestoS3FileSystemStats;
import org.apache.hadoop.conf.Configuration;

import javax.annotation.concurrent.GuardedBy;
Expand Down Expand Up @@ -106,13 +105,11 @@ private AmazonS3 createS3Client(Configuration config)
.withUserAgentPrefix(userAgentPrefix)
.withUserAgentSuffix(enabled ? "presto-select" : "presto");

PrestoS3FileSystemStats stats = new PrestoS3FileSystemStats();
RequestMetricCollector metricCollector = new PrestoS3FileSystemMetricCollector(stats);
AWSCredentialsProvider awsCredentialsProvider = getAwsCredentialsProvider(config, defaults);
AmazonS3Builder<? extends AmazonS3Builder<?, ?>, ? extends AmazonS3> clientBuilder = AmazonS3Client.builder()
.withCredentials(awsCredentialsProvider)
.withClientConfiguration(clientConfiguration)
.withMetricsCollector(metricCollector)
.withMetricsCollector(new PrestoS3FileSystemMetricCollector(PrestoS3FileSystem.getFileSystemStats()))
.enablePathStyleAccess();

boolean regionOrEndpointSet = false;
Expand Down

0 comments on commit 0e24cb7

Please sign in to comment.