繁体   English   中英

使用 Micrometer 检测 AWS 异步客户端 sdk 线程池

[英]Instrumenting AWS async client sdk threadpool with Micrometer

我试图了解检测 AWS 异步客户端使用的默认线程池执行程序的最佳方法。 来源 我们正在使用 Micrometer 来跟踪所有指标。

我的目的是了解我是否应该使用自定义线程池执行程序,或者默认的线程池执行程序是否足够好。

我当前的代码如下(并且按预期工作):

//use the same thread pool executor as the aws sdk but instrument it.
int processors = Runtime.getRuntime().availableProcessors();
int corePoolSize = Math.max(8, processors);
int maxPoolSize = Math.max(64, processors * 2);
ThreadPoolExecutor executor = new ThreadPoolExecutor(corePoolSize, maxPoolSize,
                10, TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(1_000),
                new ThreadFactoryBuilder()
                        .threadNamePrefix("sdk-async-response").build());
// Allow idle core threads to time out
executor.allowCoreThreadTimeOut(true);

var instrumentedExecutor = ExecutorServiceMetrics.monitor(meterRegistry,
                executor,
                "instrumented-ddb-executor");

return DynamoDbAsyncClient.builder()
                .asyncConfiguration(b -> b.advancedOption(FUTURE_COMPLETION_EXECUTOR, instrumentedExecutor))
                .build();

我觉得有一种更简单的方法,但找不到。 有没有更简单的方法来检测而无需重新定义默认执行程序?

您可以覆盖千分尺的默认指标收集器:这是我的实现: https://gist.github.com/PatrykGala/e4aec004eb55cd8cbdee328f217771c7

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM