LangGraph Observability and Monitoring (Python)
LangGraph Observability and Monitoring (Python)
Section titled “LangGraph Observability and Monitoring (Python)”Last verified: 2025-11 • Source: langchain-ai/langgraph
Tracing
Section titled “Tracing”- Wrap node execution with OpenTelemetry spans
- Attributes: graph, node, attempt, duration, tokens, errors
from opentelemetry import tracetracer = trace.get_tracer(__name__)
def traced_node(fn): def wrapper(state): with tracer.start_as_current_span(fn.__name__) as span: span.set_attribute("graph.node", fn.__name__) try: out = fn(state) return out except Exception as e: span.record_exception(e) span.set_status(trace.Status(trace.StatusCode.ERROR)) raise return wrapperMetrics
Section titled “Metrics”- Emit per-node counters and histograms (attempts, latency)
- Export via Prometheus or OTLP
- Structured logs with run/trace IDs and node names