Frameworks
Call observra.instrument() after configure() to patch installed supported agent frameworks:
import observra
observra.configure(gateway_key="obs_live_xxx")
observra.instrument()
The operation is idempotent. Unsupported or unavailable framework integrations are skipped without breaking provider routing.
Supported frameworks
| Framework | Instrumentation |
|---|---|
| LangChain | LLM, chain, tool, and agent lifecycle spans |
| LangGraph | LangGraph runs through LangChain instrumentation; agent, chain, and LLM hierarchy |
| LlamaIndex | LLM and framework callback spans |
| CrewAI | Crew and task lifecycle spans |
| Semantic Kernel | Kernel and chat-completion spans |
Provider routing itself comes from configure(). Framework instrumentation adds higher-level spans; it is not required for direct provider SDK or raw httpx traffic.
LangChain
import os
import observra
from langchain_openai import ChatOpenAI
observra.configure(gateway_key=os.environ["OBSERVRA_GATEWAY_KEY"])
observra.instrument()
model = ChatOpenAI(
model="mistral-small-latest",
api_key=os.environ["MISTRAL_API_KEY"],
base_url="https://api.mistral.ai/v1",
)
print(model.invoke("Explain observability in one sentence.").content)
LangGraph
from langgraph.graph import END, START, StateGraph
workflow = StateGraph(dict)
workflow.add_node("answer", lambda state: {"answer": model.invoke(state["question"]).content})
workflow.add_edge(START, "answer")
workflow.add_edge("answer", END)
result = workflow.compile().invoke({"question": "Explain observability in one sentence."})
print(result["answer"])
With instrumentation enabled, the graph, node, and model call appear as a parent-child trace hierarchy.
Version safety
Framework integrations are version-aware. When a framework changes beyond a supported API, Observra logs and skips the affected patch rather than applying an unsafe monkey patch. Provider routing remains available for supported httpx hosts.
Examples
Use the LangChain and LangGraph scripts above as the framework integration pattern for
CrewAI, LlamaIndex, and Semantic Kernel: configure Observra first, then call
observra.instrument() before framework work begins.