Skip to main content

Lanternfish docs

Build from first trace to first briefing

Browse documentation
L
Integration

LangGraph

Tracing for LangGraph applications through the LangChain integration: graph nodes, LLM calls and tool calls.

Prerequisites

  • LangGraph installed
  • Lanternfish SDK installed
1

Install the SDK

bash
pip install "lanternfish[langchain]"
2

Initialize with auto-instrument

python
import os
import lanternfish
from langgraph.graph import StateGraph, END
from typing import TypedDict

# Simply call instrument() and LangGraph execution is auto-traced!
lanternfish.instrument(
    api_key=os.environ["LANTERNFISH_API_KEY"],
    endpoint=os.environ["LANTERNFISH_ENDPOINT"],
)

class AgentState(TypedDict):
    messages: list
    next_step: str

workflow = StateGraph(AgentState)
workflow.add_node("researcher", researcher_node)
workflow.add_node("writer", writer_node)
workflow.add_edge("researcher", "writer")
workflow.add_edge("writer", END)
workflow.set_entry_point("researcher")

app = workflow.compile()
3

Use as normal — tracing is automatic

python
# Run your graph — every step is traced
result = app.invoke({
    "messages": [{"role": "user", "content": "Write about AI"}],
    "next_step": "research",
})

# Lanternfish captures: graph structure, node execution,
# state transitions, checkpoints, streaming events

What Lanternfish captures

  • Complete trace timeline
  • Token usage and cost
  • Latency metrics
  • Tool and function calls
  • Error tracking
  • Model information

Next steps