Repository navigation
feat(server-utils): Decide gen_ai content recording per call for OpenAI - #26464
Open
sentry-junior[bot] wants to merge 5 commits into
Open
sentry-junior[bot] wants to merge 5 commits into
sentry-junior[bot] wants to merge 5 commits into
Conversation
recordInputs and recordOutputs of openAIIntegration, instrumentOpenAiClient, groqIntegration and togetherAIIntegration can be functions that decide per call. They get the operation and the request params, and run once when the call starts, in the caller's async context. Co-Authored-By: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
Contributor
size-limit report 📦Compared: 0a411f9 (PR test merge using develop at bc2c361) Against: 524bd26 (develop) · base run #66453
|
This was referenced Nov 17, 2026
Draft
Contributor
Optional E2E testsSome optional checks were not successful. They do not block the merge. 1 not successful, 60 successful. See the run.
Successful checks
|
mydea
reviewed
Nov 17, 2026
Replaces the OpenAI unit tests for per-call recording options with one node integration test that runs the real openai client.
mydea
reviewed
Nov 17, 2026
mydea
marked this pull request as ready for review
November 17, 2026 12:49
javascript-sdk-gitflow
Bot
requested review from
RulaKhaled,
andreiborza and
timfish
November 17, 2026 12:49
…t suite Co-Authored-By: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
timfish
approved these changes
Nov 17, 2026
andreiborza
approved these changes
Nov 17, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
recordInputsandrecordOutputsofopenAIIntegration,instrumentOpenAiClient,groqIntegrationandtogetherAIIntegrationcan now be functions that decide for each call:The function gets the gen_ai operation and the request params as passed to the SDK method. It runs once when the call starts, in the caller's async context, so it can read request-scoped state such as the scope or an
AsyncLocalStorage.undefinedfalls back todataCollection.genAI. If the function throws, that content is not recorded, and the call itself is not affected.Why
Today the only per-call control is to record everything and remove content in
beforeSendSpan. That means keeping a list of content attributes that breaks every time an integration records a new one. Junior hit this twice in one week, withgen_ai.tool.definitionsandgen_ai.embeddings.input(getsentry/junior#3555, getsentry/junior#3558).This is the base of a stack. It adds the shared
GenAiCallOptions<TCall>type and resolver, and uses them in the OpenAI-shaped integrations. Integrations keep the boolean-onlyGenAiOptionsuntil their PR lands, so a function is never silently ignored. Each follow-up gives its integrations their own call info that passes the library's request as-is:Decisions:
recordOutputsis decided at call start, not from the response. A streamed response settles outside the caller's context, and the stream only builds up output content when outputs are recorded.instrumentOpenAiClientnow reads the recording options on each call instead of once when the client is wrapped, sodataCollection.genAIis read per call too.via @mydea.
--
View Session [Sentry]