Skip to content

feat: Instrument OpenAI agents api (openai.beta.agents) - #2471

Open
Luca Forstner (lforst) wants to merge 2 commits into
mainfrom
lforst/dum-e/beirut-1827d13283
Open

feat: Instrument OpenAI agents api (openai.beta.agents)#2471
Luca Forstner (lforst) wants to merge 2 commits into
mainfrom
lforst/dum-e/beirut-1827d13283

Conversation

@lforst

Copy link
Copy Markdown
Member

No description provided.

Comment thread js/src/logger.ts
}

/** @internal */
export function _internalExportParentSynchronously(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like it has a lot more slop (reflect calls?) then exportSpanSynchronously had

Comment on lines +20 to +22
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it returns

value.root.length > 0 &&
typeof value.rootKey === "string" &&
value.rootKey.length > 0 &&
typeof value.rootParent === "string" &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should clean these conditionals up

try {
decoded = JSON.parse(token.slice(TOKEN_PREFIX.length));
} catch {
throw new TypeError("Invalid OpenAI Agents trace token");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think we need to be this defensive, also json parsing feels wrong

Comment on lines +188 to +199
const parent = _internalExportParentSynchronously(getSpanParentObject());
if (!parent) {
return encodeToken(null);
}
const parentComponents = SpanComponentsV4.fromStr(parent);
const rowId = newId();
const useLegacyIds = resolveUseLegacyUuidIds();
const spanId = useLegacyIds
? newId()
: newId().replaceAll("-", "").slice(0, 16);
const rootSpanId = useLegacyIds ? spanId : newId().replaceAll("-", "");
const root = new SpanComponentsV4({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel like all of this should be a helper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants