-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JMX metrics for S3 http client usage in native FS
When s3 client was changed to use AWS SDK v2 from AWS SDK v1, the set of s3 pool metrics were missed. With this PR, these http pool metrics are now exposed via JMX beans. The reference for the http metrics exposed by AWS SDK can be found here: https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/http/HttpMetric.html
- Loading branch information
1 parent
af4e200
commit 8c127bf
Showing
2 changed files
with
110 additions
and
4 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
lib/trino-filesystem-s3/src/main/java/io/trino/filesystem/s3/AwsSdkV2HttpClientStats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Licensed 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 io.trino.filesystem.s3; | ||
|
||
import com.google.errorprone.annotations.ThreadSafe; | ||
import io.airlift.stats.DistributionStat; | ||
import io.airlift.stats.TimeStat; | ||
import org.weakref.jmx.Managed; | ||
import org.weakref.jmx.Nested; | ||
import software.amazon.awssdk.metrics.SdkMetric; | ||
|
||
import java.time.Duration; | ||
|
||
import static java.util.concurrent.TimeUnit.MILLISECONDS; | ||
import static software.amazon.awssdk.http.HttpMetric.AVAILABLE_CONCURRENCY; | ||
import static software.amazon.awssdk.http.HttpMetric.LEASED_CONCURRENCY; | ||
import static software.amazon.awssdk.http.HttpMetric.PENDING_CONCURRENCY_ACQUIRES; | ||
|
||
@ThreadSafe | ||
public class AwsSdkV2HttpClientStats | ||
{ | ||
private final TimeStat connectionAcquireLatency = new TimeStat(MILLISECONDS); | ||
private final DistributionStat availableConcurrency = new DistributionStat(); | ||
private final DistributionStat leasedConcurrency = new DistributionStat(); | ||
private final DistributionStat pendingConcurrencyAcquires = new DistributionStat(); | ||
|
||
@Managed | ||
@Nested | ||
public TimeStat getConnectionAcquireLatency() | ||
{ | ||
return connectionAcquireLatency; | ||
} | ||
|
||
@Managed | ||
@Nested | ||
public DistributionStat getAvailableConcurrency() | ||
{ | ||
return availableConcurrency; | ||
} | ||
|
||
@Managed | ||
@Nested | ||
public DistributionStat getLeasedConcurrency() | ||
{ | ||
return leasedConcurrency; | ||
} | ||
|
||
@Managed | ||
@Nested | ||
public DistributionStat getPendingConcurrencyAcquires() | ||
{ | ||
return pendingConcurrencyAcquires; | ||
} | ||
|
||
public void updateConcurrencyStats(SdkMetric<?> metric, int value) | ||
{ | ||
if (metric.equals(AVAILABLE_CONCURRENCY)) { | ||
availableConcurrency.add(value); | ||
} | ||
else if (metric.equals(PENDING_CONCURRENCY_ACQUIRES)) { | ||
pendingConcurrencyAcquires.add(value); | ||
} | ||
else if (metric.equals(LEASED_CONCURRENCY)) { | ||
leasedConcurrency.add(value); | ||
} | ||
} | ||
|
||
public void updateConcurrencyAcquireDuration(Duration duration) | ||
{ | ||
connectionAcquireLatency.addNanos(duration.toNanos()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters