Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to use ThreadPoolExecutor in SegmentContextExecutors.newSegmentContextExecutor() #322

Open
task4233 opened this issue Feb 23, 2022 · 1 comment
Assignees

Comments

@task4233
Copy link

Hello,

Currently, SegmentContextExecutors.newSegmentContextExecutor provides an Executor which uses ForkJoinPool.commonPool().

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.

@wangzlei
Copy link
Contributor

Thanks for raising this question. Yes, the current SegmentContextExecutor only run runnable in ForkJoin common pool. We should improve it to wrap an Executor user provides in input param. I label this as a feature.
Currently we shift the emphasis to OpenTelemetry, we suggest xray user try to migrate to OpenTelemetry.
https://github.com/open-telemetry/opentelemetry-java/blob/main/context/src/main/java/io/opentelemetry/context/Context.java#L233

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants