Skip to content

feat(typesafe): add JavaScript SDK instrumentation - #3779

Merged
mikeldking merged 16 commits into
mainfrom
feat/typesafe-js-instrumentation
Sep 18, 2026
Merged

mikeldking merged 16 commits into
mainfrom
feat/typesafe-js-instrumentation

Conversation

@mikeldking

@mikeldking mikeldking commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds @arizeai/openinference-instrumentation-typesafe: one OpenInference LLM span per TypeSafeClient.systemOne call, with JSON input.value / output.value, resolved model, token usage, and provider/system typesafe.

Closes #3770.

Phoenix verification

Verified against local Phoenix with the package examples:

  • typesafe-basic-usage-20260917-2038 — single TypeSafeClient.systemOne LLM span with structured JSON input/output
  • typesafe-guardrail-routing — support.route chain with TypeSafe + OpenAI LLM children, session, and workflow metadata

@pkg-pr-new

pkg-pr-new Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@arizeai/openinference-core

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-core@3779

@arizeai/openinference-genai

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-genai@3779

@arizeai/openinference-instrumentation-anthropic

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-anthropic@3779

@arizeai/openinference-instrumentation-bedrock

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-bedrock@3779

@arizeai/openinference-instrumentation-bedrock-agent-runtime

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-bedrock-agent-runtime@3779

@arizeai/openinference-instrumentation-beeai

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-beeai@3779

@arizeai/openinference-instrumentation-claude-agent-sdk

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-claude-agent-sdk@3779

@arizeai/openinference-instrumentation-langchain

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-langchain@3779

@arizeai/openinference-instrumentation-langchain-v0

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-langchain-v0@3779

@arizeai/openinference-instrumentation-mcp

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-mcp@3779

@arizeai/openinference-instrumentation-openai

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-openai@3779

@arizeai/openinference-instrumentation-openai-agents

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-openai-agents@3779

@arizeai/openinference-instrumentation-typesafe

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-typesafe@3779

@arizeai/openinference-semantic-conventions

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-semantic-conventions@3779

@arizeai/openinference-tanstack-ai

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-tanstack-ai@3779

@arizeai/openinference-vercel

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-vercel@3779

commit: 61f3e0b

@mikeldking
mikeldking marked this pull request as ready for review September 18, 2026 01:11
@mikeldking
mikeldking requested review from a team as code owners September 18, 2026 01:11
mikeldking and others added 2 commits September 17, 2026 19:14
Resolve merge conflicts keeping structured JSON payloads, add TypeSafe
to Go semconv, and ignore LiteLLM model-price fetches in dspy VCR so
Python CI Required can pass.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown
Contributor

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread js/packages/openinference-instrumentation-typesafe/src/attributes.ts Outdated
Comment thread js/packages/openinference-instrumentation-typesafe/src/attributes.ts Outdated
Comment thread js/packages/openinference-instrumentation-typesafe/README.md Outdated
Comment thread js/packages/openinference-instrumentation-typesafe/README.md Outdated
Comment thread js/packages/openinference-instrumentation-typesafe/README.md
Comment thread js/packages/openinference-instrumentation-typesafe/README.md Outdated
mikeldking and others added 2 commits September 17, 2026 20:46
Drop the SC alias for destructured SemanticConventions keys, set
llm.request/response.model_name, and trim the README to publishable usage docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Reuse core getLLMAttributes/withSafety, skip payload stringify when
masked, and prefer the SDK parse for await paths so clone JSON is only
used for asResponse-only observation.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread js/packages/openinference-instrumentation-typesafe/src/attributes.ts Outdated
Comment thread js/packages/openinference-instrumentation-typesafe/src/attributes.ts Outdated
Record the actual systemOne request/response in input/output values
without injecting the resolved model, let OITracer handle masking, and
punt instrumentor-owned metadata for now.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown
Contributor

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

mikeldking and others added 2 commits September 17, 2026 22:51
Simplify response attribute extraction, replace masking asides with
self-contained JSDoc, and accept @typesafe-ai/sdk >=0.6.0 without an
upper bound.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@mikeldking
mikeldking requested a review from a team as a code owner September 18, 2026 04:56
@github-actions

Copy link
Copy Markdown
Contributor

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Keep verification images out of git; they belong on the PR via upload, not the repo.

Co-authored-by: Cursor <cursoragent@cursor.com>
mikeldking and others added 2 commits September 17, 2026 23:03
Keep the JS instrumentation PR scoped to JavaScript; cross-language
semconv and the dspy VCR tweak belong elsewhere.

Co-authored-by: Cursor <cursoragent@cursor.com>
Match the shared instrumentation README structure/footer and remove the
low-signal CJS/ESM subprocess coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown
Contributor

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

The APIPromise parse callback had no error handling, so a rejection
raised after a successful HTTP response (e.g. body parsing failing)
was never recorded on the span. The fallback path had already
declined to end it, and the raw-response rejection handler only
fires when the request itself fails.

Route both async failure paths through an `endError` helper gated on
the same `ended` flag as `endOk`, so the span is ended exactly once
and an HTTP failure is not recorded twice.
The Examples section still carried repo-local `cd` / `pnpm install`
/ `pnpm -r build` commands and a relative `./examples/` link.
`files` is `["dist","src"]`, so `examples/` is not published and
neither renders usefully on npm.

Point at the examples directory on GitHub with an absolute URL,
matching openinference-core.
"api.minimax.io": LLMProvider.MINIMAX,
"api.minimaxi.com": LLMProvider.MINIMAX,
"api.minimax.chat": LLMProvider.MINIMAX,
"api.typesafe.ai": LLMProvider.TYPESAFE,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what is this change for? Why in openai instr?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is if typesafe got used through openai, which it wouldn't. so I'll remove

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed in 61f3e0b — both the HOST_SUFFIX_TO_PROVIDER entry and its test case are gone, so openinference-instrumentation-openai/src/instrumentation.ts now matches main.

One knock-on change remains in that package: LLMProvider.TYPESAFE stays in the semantic conventions (the Typesafe instrumentor sets llm.provider/llm.system), and the existing every provider has at least one host entry test enumerates Object.values(LLMProvider), so dropping the mapping made it fail. The test now skips providers listed in a new PROVIDERS_WITHOUT_OPENAI_COMPATIBLE_HOST set, which holds TYPESAFE only. Happy to invert it (assert against an explicit expected list instead) if you would rather not carry an exemption set there.

pnpm run test and type:check pass for the openai package.

…tion

The `api.typesafe.ai` suffix was added to `HOST_SUFFIX_TO_PROVIDER` so an
OpenAI client pointed at Typesafe would be attributed correctly, but the
Typesafe SDK is not OpenAI-compatible, so that path does not exist. Remove
the mapping and its test case.

`LLMProvider.TYPESAFE` stays in the semantic conventions (the Typesafe
instrumentor sets it), so the OpenAI package's "every provider has at least
one host entry" test needs an explicit exemption for providers that are not
reachable through an OpenAI-compatible endpoint.
@github-actions

Copy link
Copy Markdown
Contributor

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@mikeldking
mikeldking merged commit 5a075b9 into main Sep 18, 2026
23 checks passed
@mikeldking
mikeldking deleted the feat/typesafe-js-instrumentation branch September 18, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[feature request] Add OpenInference auto-instrumentation for the TypeSafe AI JS/TS SDK (@typesafe-ai/sdk)

2 participants