Allow custom executor/thread pool for async HTTP calls in CompletionServiceAsyncImpl
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 65/100
Direzione di ricerca
Inizia dall’uso dell’executor indicato in openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsyncImpl.kt, quindi segui OpenAIClient.builder() per trovare dove viene assemblata la configurazione del client. Determina come l’executor configurato debba raggiungere il servizio asincrono e verifica che le chiamate HTTP asincrone lo utilizzino invece di ForkJoinPool.commonPool().
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Kotlin
- Stelle
- 1.5k
- Fork
- 264
- Merge medio
- 13h 31m
- PR unite (30g)
- 89
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di openai/openai-java
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
openai/openai-java#890 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
openai/openai-java#886 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
openai/openai-java#802 · 2 commenti · 3 reazioni ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
openai/openai-java#755 · 1 commento ·
-
bug sdk
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
openai/openai-java#652 · 2 commenti ·
Tutte le issue di openai/openai-java
Issue simili
-
[Bug] 统计页面无法重置token和汇率 Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
AAswordman/Operit#1265 · 3 commenti ·
-
Tambahkan bahasa Indonesia Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
acristescu/OnlineGo#216 ·
-
Remove custom segment colors Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
libre-tube/LibreTube#8803 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
status: waiting-for-triage type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
spring-projects/spring-security#19781 ·