Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(js): set spans from instrumentation active span on context in OpenAI instrumentor #1121

Merged
merged 5 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions js/.changeset/dirty-candles-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@arizeai/openinference-instrumentation-openai": patch
---

fix: propgate context to spans created as a result of work done within openai calls
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,12 @@ export class OpenAIInstrumentation extends InstrumentationBase<typeof openai> {
},
},
);

const execContext = getExecContext(span);
const execPromise = safeExecuteInTheMiddle<
ReturnType<ChatCompletionCreateType>
>(
() => {
return context.with(execContext, () => {
return context.with(trace.setSpan(execContext, span), () => {
return original.apply(this, args);
});
},
Expand Down Expand Up @@ -263,7 +262,7 @@ export class OpenAIInstrumentation extends InstrumentationBase<typeof openai> {
ReturnType<CompletionsCreateType>
>(
() => {
return context.with(execContext, () => {
return context.with(trace.setSpan(execContext, span), () => {
return original.apply(this, args);
});
},
Expand Down Expand Up @@ -335,7 +334,7 @@ export class OpenAIInstrumentation extends InstrumentationBase<typeof openai> {
ReturnType<EmbeddingsCreateType>
>(
() => {
return context.with(execContext, () => {
return context.with(trace.setSpan(execContext, span), () => {
return original.apply(this, args);
});
},
Expand Down
Loading