-
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
4971ef1
commit 75f05b0
Showing
2 changed files
with
107 additions
and
4 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
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,80 @@ | ||
/* | ||
* 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.TimeStat; | ||
import org.weakref.jmx.Managed; | ||
import org.weakref.jmx.Nested; | ||
import software.amazon.awssdk.metrics.SdkMetric; | ||
|
||
import java.time.Duration; | ||
import java.util.concurrent.atomic.AtomicLong; | ||
|
||
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 AtomicLong availableConcurrency = new AtomicLong(); | ||
private final AtomicLong leasedConcurrency = new AtomicLong(); | ||
private final AtomicLong pendingConcurrencyAcquires = new AtomicLong(); | ||
|
||
@Managed | ||
@Nested | ||
public TimeStat getConnectionAcquireLatency() | ||
{ | ||
return connectionAcquireLatency; | ||
} | ||
|
||
@Managed | ||
public long getAvailableConcurrency() | ||
{ | ||
return availableConcurrency.get(); | ||
} | ||
|
||
@Managed | ||
public long getLeasedConcurrency() | ||
{ | ||
return leasedConcurrency.get(); | ||
} | ||
|
||
@Managed | ||
public long getPendingConcurrencyAcquires() | ||
{ | ||
return pendingConcurrencyAcquires.get(); | ||
} | ||
|
||
public void updateConcurrencyStats(SdkMetric<?> metric, int value) | ||
{ | ||
if (metric.equals(AVAILABLE_CONCURRENCY)) { | ||
availableConcurrency.set(value); | ||
} | ||
else if (metric.equals(PENDING_CONCURRENCY_ACQUIRES)) { | ||
pendingConcurrencyAcquires.set(value); | ||
} | ||
else if (metric.equals(LEASED_CONCURRENCY)) { | ||
leasedConcurrency.set(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