Traces
LangSmith Traces
Bridge LangSmith OpenTelemetry spans to the Inference platform tracer provider.
If your application already uses LangSmith tracing, Inference platform can bridge
LangSmith OpenTelemetry spans to the Inference platform tracer provider. This keeps
LangSmith traceable functions and framework integrations visible with the rest
of your application traces.
If a LangSmith-traced function is the boundary of an agent run, add an outer
agentSpan() / agent_span() with a stable agent.id. LangSmith spans remain
visible under that AGENT span.
Install
TypeScript Traceable Function
import { setup } from "@inference/tracing";
import { Client } from "langsmith";
import { traceable } from "langsmith/traceable";
process.env.LANGSMITH_TRACING = "true";
process.env.LANGSMITH_TRACING_MODE = "otel";
const tracing = await setup({ serviceName: "langsmith-worker" });
const client = new Client({ tracingMode: "otel" });
const answerQuestion = traceable(
async (input: { question: string }) => ({
answer: input.question.toUpperCase(),
}),
{
name: "answerQuestion",
run_type: "tool",
client,
tracer: tracing.provider.getTracer("langsmith-app"),
},
);
console.log(await answerQuestion({ question: "hi" }));
await client.flush();
await tracing.shutdown();Python Traceable Function
import os
from inference_tracing import setup
from langsmith import Client, traceable
os.environ["LANGSMITH_TRACING"] = "true"
os.environ["LANGSMITH_TRACING_MODE"] = "otel"
tracing = setup(service_name="langsmith-worker")
client = Client()
@traceable(name="answer_question", run_type="tool", client=client, enabled=True)
def answer_question(question: str) -> str:
return question.upper()
print(answer_question("hi"))
client.flush()
tracing.shutdown()Hybrid Mode
If LANGSMITH_TRACING=true is set and LANGSMITH_TRACING_MODE is not set,
Inference Tracing defaults LangSmith to hybrid mode. That keeps existing LangSmith
tracing active while also routing OpenTelemetry spans through the Inference platform.
export LANGSMITH_TRACING=true
# Inference Tracing sets LANGSMITH_TRACING_MODE=hybrid when unset.Stable Agent Identity
Use this pattern around LangSmith-traced work when you want the Agents dashboard to group executions by your product agent ID.