A way to use ThreadPoolExecutor in SegmentContextExecutors.newSegmentContextExecutor()
- Dominant language
- Java
- Stars
- 100
- Forks
- 100
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
Currently, `SegmentContextExecutors.newSegmentContextExecutor` provides an Executor [which uses `ForkJoinPool.commonPool()`](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html#:~:text=All%20async%20methods%20without%20an%20explicit%20Executor%20argument%20are%20performed%20using%20the%20ForkJoinPool.commonPool()%20(unless%20it%20does%20not%20support%20a%20parallelism%20level%20of%20at%20least%20two%2C%20in%20which%20case%2C%20a%20new%20Thread%20is%20created%20to%20run%20each%20task)).
However, as `ForkJoinPool.commonPool()` spends a long time on heavy tasks including I/O processing such as HTTP connections, there is a demand for using `ThreadPoolExecutor` which is shared in a single task queue.
For now, this problem might be resolved by using the setTraceEntity()` as below.
```
final Entity entity = AWSXRay.getTraceEntity();
CompletableFuture completableFuture = CompletableFuture.supplyAsync(
() -> {
AWSXRay.setTraceEntity(entity);
// do something ...
}, customedThreadPool);
```
However, as `setTraceEntity()` is deprecated, this way is not good for the future. Hence, if there's a way to resolve this problem, I'd like to know that.
Thanks in advance.
Contributor guide
Assessment
This issue has not been assessed yet.