Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.tracectrl.ai/llms.txt

Use this file to discover all available pages before exploring further.

Installation

tracectrl is on PyPI. The LangChain instrumentor is not yet published — install it from the source tree.
pip install tracectrl
pip install ./sdk/tracectrl-instrumentation-langchain
PyPI publication of tracectrl-instrumentation-langchain is pending. Until then, install from a local checkout or via pip install git+https://github.com/cloudsine/tracectrl.git#subdirectory=sdk/tracectrl-instrumentation-langchain.

Usage

import tracectrl
from tracectrl import tag_agent
from tracectrl.instrumentation.langchain import LangChainInstrumentor

tracectrl.configure(service_name="my-langchain-agent")
LangChainInstrumentor().instrument()

from langchain_openai import ChatOpenAI
from langchain.agents import create_openai_tools_agent, AgentExecutor

llm = ChatOpenAI(model="gpt-4o")
# ... define tools, prompt, agent
agent_executor = AgentExecutor(agent=agent, tools=tools)
tag_agent(agent_executor)

agent_executor.invoke({"input": "Summarize my latest emails"})
Call tag_agent(agent_executor) (or, for LangGraph, on the compiled graph) so the agent identity propagates onto every span the run produces.

What Gets Captured

Span KindExamplesAttributes Set
CHAINChain/pipeline runsinput.value, output.value
LLMChatOpenAI, ChatAnthropicllm.model_name, llm.system
TOOLTool invocationstool.name, tool.description, tracectrl.tool.category
AGENTAgentExecutor runstracectrl.agent.id, tracectrl.agent.name
RETRIEVERVector store retrievalsretrieval.documents

LangGraph Support

LangGraph agents are automatically captured — each node execution appears as a span with parent-child relationships matching the graph structure.
from langgraph.graph import StateGraph

graph = StateGraph(MyState)
graph.add_node("researcher", researcher_node)
graph.add_node("writer", writer_node)
compiled = graph.compile()
tag_agent(compiled)

API

LangChainInstrumentor()

instrument
method
instrument(tracer_provider=None, skip_dep_check=False) — Registers the TraceCtrl span processor and wraps the OpenInference LangChain instrumentor.
uninstrument
method
uninstrument() — Shuts down the TraceCtrl processor and unwraps the OpenInference instrumentor.
instrumented
bool
Whether the instrumentor is currently active.