Allow custom executor/thread pool for async HTTP calls in CompletionServiceAsyncImpl
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
まず openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsyncImpl.kt の参照されている executor の使用箇所から始め、次に OpenAIClient.builder() をたどって、クライアント設定がどこで組み立てられているかを確認します。設定済みの executor が非同期サービスにどのように渡されるべきかを判断し、非同期 HTTP 呼び出しが ForkJoinPool.commonPool() ではなくそれを使用していることを検証します。
索引モデルが issue の本文から書いたものです。
説明
Description
CompletionServiceAsyncImpl currently uses the JVM ForkJoinPool.commonPool() to invoke async HTTP calls:
In enterprise environments, relying on the global common pool can break tracing, observability, and context propagation flows. Many applications use custom executors/thread pools to preserve tracing context, MDC/logging context, OpenTelemetry context, or other request-scoped metadata across async boundaries.
Because the common pool is not customizable, users cannot currently integrate the OpenAI Java client cleanly with their existing execution and observability infrastructure.
Problem
There is currently no supported way to override the thread pool used by CompletionServiceAsyncImpl.
The only workaround is to copy the generated/service implementation class and modify the executor usage manually, which is fragile and difficult to maintain across library upgrades.
Proposed Solution
Provide an option to configure the executor/thread pool when building the client.
For example:
val client = OpenAIClient.builder()
.apiKey(apiKey)
.executor(customExecutor)
.build()
or, if scoped specifically to async execution:
val client = OpenAIClient.builder()
.apiKey(apiKey)
.asyncExecutor(customExecutor)
.build()
The async service implementation could then use the configured executor instead of ForkJoinPool.commonPool().
Expected Behavior
Users should be able to supply a custom executor so async HTTP calls run on infrastructure-controlled threads, allowing tracing, observability, and context propagation to work correctly.
Current Workaround
The current workaround is to copy CompletionServiceAsyncImpl and modify the implementation to use a custom executor, but this is not ideal because it forks library internals and creates maintenance risk.
Additional Context
This is especially important in enterprise scenarios where applications require strict control over execution context, thread naming, tracing propagation, and monitoring behavior.
- 主要言語
- Kotlin
- スター
- 1.5k
- フォーク
- 266
- 平均マージ
- 9時間 50分
- マージ済み PR(30日)
- 146
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
openai/openai-java のほかの issue
-
HttpRequest.url() logs spaces in path segments as literal plus signs対応中かも @sylvesterkaczmarek が 53 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
openai/openai-java#886 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Make diarized transcription duration and task optional対応中かも @wskr00 が 84 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
openai/openai-java#802 · コメント 2 件 · リアクション 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 半日 初心者へのやさしさ 42/100
openai/openai-java#1160 ·
メンテナーはふだん 1 日以内に返信
-
AsyncStreamResponse can hang when the subscriber executor rejects work対応中かも @sylvesterkaczmarek が 36 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
openai/openai-java#973 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
openai/openai-java#956 ·
メンテナーはふだん 1 日以内に返信
openai/openai-java の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
utopia-rise/godot-jvm#1004 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
ankidroid/Anki-Android#22408 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1時間未満 初心者へのやさしさ 72/100
afarber/OpenMapView#22 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
nightscout/AndroidAPS#5245 ·
メンテナーはふだん 1 日以内に返信