Summary
The ruby_llm gem provides RubyLLM.batch(chats) / RubyLLM::Batch.submit(chats) for submitting multiple chat completions as a provider-side batch job (e.g., OpenAI Batch API). This API is not instrumented by this SDK. The current RubyLLM integration only instruments RubyLLM::Chat#complete — individual synchronous completions. Batch submission is a distinct generative execution path that bypasses Chat#complete entirely and produces no spans today.
What is missing
RubyLLM.batch(chats) / RubyLLM::Batch.submit(chats) — submits an array of staged Chat objects to the provider as a batch job. Returns a RubyLLM::Batch object. The underlying provider API (e.g., OpenAI /v1/batches) queues the completions for asynchronous generation, typically completing within hours at reduced cost.
Key execution surface:
Batch.submit(chats) — the batch creation call: sends all queued chat requests to the provider. This is where a span should be created.
batch.messages — retrieves completed results (polling/retrieval; CRUD, out of scope).
What a span should capture
- Input: number of chats submitted, model(s), provider
- Metadata: batch
id (returned by provider), provider, endpoint (e.g., /v1/batches), status on creation
- Output: batch ID and initial status
- Metrics:
request_counts (total requests submitted), latency of the submit call
The span should be created at submit time, not at result retrieval time, since that is when the generative execution is initiated.
Why Chat#complete instrumentation does not cover this
Batch.submit calls the provider's batch API directly — it does not call Chat#complete for each chat. Staged chats have their requests serialized and sent as a single batch request. The existing ChatPatcher (which wraps Chat#complete) fires zero times during batch submission.
Braintrust docs status
not_found — The Braintrust RubyLLM integration docs at https://www.braintrust.dev/docs/integrations/sdk-integrations/ruby-llm document only chat completions, tool calls, token usage, and streaming. Batch processing is not mentioned.
Upstream sources
Local repo files inspected
lib/braintrust/contrib/ruby_llm/patcher.rb — defines only ChatPatcher (wraps Chat#complete); no BatchPatcher
lib/braintrust/contrib/ruby_llm/instrumentation/chat.rb — wraps Chat#complete and Chat#execute_tool only; Batch.submit takes a completely separate code path
lib/braintrust/contrib/ruby_llm/integration.rb — registers [ChatPatcher] only
- Grep for
batch, Batch, BatchPatcher, submit across lib/braintrust/contrib/ruby_llm/ returns zero matches
Summary
The
ruby_llmgem providesRubyLLM.batch(chats)/RubyLLM::Batch.submit(chats)for submitting multiple chat completions as a provider-side batch job (e.g., OpenAI Batch API). This API is not instrumented by this SDK. The current RubyLLM integration only instrumentsRubyLLM::Chat#complete— individual synchronous completions. Batch submission is a distinct generative execution path that bypassesChat#completeentirely and produces no spans today.What is missing
RubyLLM.batch(chats)/RubyLLM::Batch.submit(chats)— submits an array of stagedChatobjects to the provider as a batch job. Returns aRubyLLM::Batchobject. The underlying provider API (e.g., OpenAI/v1/batches) queues the completions for asynchronous generation, typically completing within hours at reduced cost.Key execution surface:
Batch.submit(chats)— the batch creation call: sends all queued chat requests to the provider. This is where a span should be created.batch.messages— retrieves completed results (polling/retrieval; CRUD, out of scope).What a span should capture
id(returned by provider), provider, endpoint (e.g.,/v1/batches), status on creationrequest_counts(total requests submitted), latency of the submit callThe span should be created at submit time, not at result retrieval time, since that is when the generative execution is initiated.
Why
Chat#completeinstrumentation does not cover thisBatch.submitcalls the provider's batch API directly — it does not callChat#completefor each chat. Staged chats have their requests serialized and sent as a single batch request. The existingChatPatcher(which wrapsChat#complete) fires zero times during batch submission.Braintrust docs status
not_found— The Braintrust RubyLLM integration docs at https://www.braintrust.dev/docs/integrations/sdk-integrations/ruby-llm document only chat completions, tool calls, token usage, and streaming. Batch processing is not mentioned.Upstream sources
Batchclass: https://github.com/crmne/ruby_llm/blob/main/lib/ruby_llm/batch.rbbatchmethod: https://github.com/crmne/ruby_llm/blob/main/lib/ruby_llm.rbLocal repo files inspected
lib/braintrust/contrib/ruby_llm/patcher.rb— defines onlyChatPatcher(wrapsChat#complete); noBatchPatcherlib/braintrust/contrib/ruby_llm/instrumentation/chat.rb— wrapsChat#completeandChat#execute_toolonly;Batch.submittakes a completely separate code pathlib/braintrust/contrib/ruby_llm/integration.rb— registers[ChatPatcher]onlybatch,Batch,BatchPatcher,submitacrosslib/braintrust/contrib/ruby_llm/returns zero matches