Allow custom executor/thread pool for async HTTP calls in CompletionServiceAsyncImpl
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 65/100
Hướng nghiên cứu
Bắt đầu với chỗ sử dụng executor được tham chiếu trong openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsyncImpl.kt, sau đó lần theo OpenAIClient.builder() để tìm nơi cấu hình client được tập hợp. Xác định executor đã cấu hình cần được truyền đến dịch vụ bất đồng bộ như thế nào, và xác minh rằng các lệnh gọi HTTP bất đồng bộ sử dụng nó thay vì ForkJoinPool.commonPool().
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Kotlin
- Star
- 1.5k
- Fork
- 264
- Merge trung bình
- 13 giờ 31 phút
- Pull request đã merge (30 ngày)
- 89
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của openai/openai-java
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
openai/openai-java#890 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
openai/openai-java#886 · 2 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
openai/openai-java#802 · 2 bình luận · 3 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
openai/openai-java#755 · 1 bình luận ·
-
bug sdk
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
openai/openai-java#652 · 2 bình luận ·
Tất cả issue của openai/openai-java
Issue tương tự
-
[Bug] 统计页面无法重置token和汇率 Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
AAswordman/Operit#1265 · 3 bình luận ·
-
Tambahkan bahasa Indonesia Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
acristescu/OnlineGo#216 ·
-
Remove custom segment colors Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
libre-tube/LibreTube#8803 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
status: waiting-for-triage type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
spring-projects/spring-security#19781 ·