JavaScript · Instrumentation
@arizeai/openinference-instrumentation-typesafe
OpenInference instrumentation for the TypeSafe AI SDK
- Version
- 0.4.7
- Node.js
- >=20
- Instruments
@typesafe-ai/sdk >=0.6.0
Install
npm install @arizeai/openinference-instrumentation-typesafeUsage
Register the instrumentation once, at startup, before the library is imported. The TypeSafeInstrumentation reference below lists its options.
import { registerInstrumentations } from "@opentelemetry/instrumentation";
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
import { TypeSafeInstrumentation } from "@arizeai/openinference-instrumentation-typesafe";
const provider = new NodeTracerProvider({
// ...a span processor that exports to Phoenix or any OTLP backend.
});
provider.register();
registerInstrumentations({
instrumentations: [new TypeSafeInstrumentation()],
});If the library is imported first (as ES modules often are), patch it directly with manuallyInstrument().
@arizeai/openinference-instrumentation-typesafe
TypeSafeInstrumentation
classSource ↗class TypeSafeInstrumentation extends InstrumentationBase<TypeSafeModule>OpenInference instrumentation for @typesafe-ai/sdk.
Emits one OpenInference DECISION span per TypeSafeClient.systemOne call,
including SDK retries. Does not instrument models.list. Request and
response bodies are recorded as JSON on input.value / output.value.
Automatic patching covers CommonJS require loads. For ESM, bundlers, or
late imports, call TypeSafeInstrumentation.manuallyInstrument.
new TypeSafeInstrumentation
constructorSource ↗new TypeSafeInstrumentation(
options?: {
instrumentationConfig?: InstrumentationConfig;
traceConfig?: TraceConfigOptions;
tracerProvider?: TracerProvider;
},
): TypeSafeInstrumentationParameters
| Name | Type | Description |
|---|---|---|
options? | { instrumentationConfig?: InstrumentationConfig; traceConfig?: TraceConfigOptions; tracerProvider?: TracerProvider } | Optional instrumentor configuration. |
options.instrumentationConfig? | InstrumentationConfig | OpenTelemetry instrumentation config. |
options.traceConfig? | TraceConfigOptions | OpenInference |
options.tracerProvider? | TracerProvider | Tracer provider used to create spans. |
setTracerProvider
methodSource ↗setTracerProvider(provider: TracerProvider): voidRebinds the instrumentor to a new tracer provider.
Parameters
| Name | Type | Description |
|---|---|---|
provider | TracerProvider | Tracer provider used for subsequent spans. |
manuallyInstrument
methodSource ↗manuallyInstrument(module: __module): voidPatches an already-imported @typesafe-ai/sdk namespace.
Use this for ESM loads, bundlers, or modules imported before the instrumentor was enabled. Safe to call for both CommonJS and ESM builds in the same process.
Parameters
| Name | Type | Description |
|---|---|---|
module | __module | The imported |
enable
methodSource ↗enable(): voiddisable
methodSource ↗disable(): void