initializeOTEL
method at the start of your code:
experimental_telemetry
argument to your AI SDK calls that you want to trace.
await DEFAULT_LANGSMITH_SPAN_PROCESSOR.shutdown();
before your application shuts down in order to flush any remaining traces to LangSmith.traceable
traceable
calls around or within AI SDK tool calls. If you do so, we recommend you initialize a LangSmith client
instance that you pass into each traceable
, then call client.awaitPendingTraceBatches();
to ensure all traces flush. If you do this, you do not need to manually call shutdown()
or forceFlush()
on the DEFAULT_LANGSMITH_SPAN_PROCESSOR
. Here’s an example:
@vercel/otel
package:
instrumentation.ts
file in your root directory.
Call initializeOTEL
and pass the resulting DEFAULT_LANGSMITH_SPAN_PROCESSOR
into the spanProcessors
field into your registerOTEL(...)
call.
It should look something like this:
initializeOTEL
as well and add an experimental_telemetry
field to your AI SDK calls:
traceables
for more granularity.
ls_run_name
into experimental_telemetry
.