Instrumentation package for LangGraph in the Codon ecosystem.
Project description
Codon LangGraph Adapter
If you're already using LangGraph, the Codon SDK provides seamless integration through the LangGraphWorkloadAdapter. This allows you to wrap your existing StateGraphs with minimal code changes while gaining comprehensive telemetry and observability.
Understanding State Graph vs Compiled Graph
LangGraph has two distinct graph representations:
- State Graph: The graph you define and add nodes to during development
- Compiled Graph: The executable version created when you want to run the graph
The LangGraphWorkloadAdapter works by wrapping your StateGraph and compiling it for you, allowing you to pass compile keyword arguments for features like checkpointers and long-term memory.
Using LangGraphWorkloadAdapter
The primary way to integrate LangGraph with Codon is through the LangGraphWorkloadAdapter.from_langgraph() method:
from langgraph.graph import StateGraph
from langgraph.checkpoint.memory import MemorySaver
from codon.instrumentation.langgraph import LangGraphWorkloadAdapter
# Your existing StateGraph
db_agent_graph = StateGraph(SQLAnalysisState)
db_agent_graph.add_node("query_resolver_node", self.query_resolver_node)
db_agent_graph.add_node("query_executor_node", self.query_executor_node)
# ... add more nodes and edges
# Wrap with Codon adapter
self._graph = LangGraphWorkloadAdapter.from_langgraph(
db_agent_graph,
name="LangGraphSQLAgentDemo",
version="0.1.0",
description="A SQL agent created using the LangGraph framework",
tags=["langgraph", "demo", "sql"],
compile_kwargs={"checkpointer": MemorySaver()}
)
Automatic Node Inference
The adapter automatically infers nodes from your StateGraph, eliminating the need to manually instrument each node with decorators. This provides comprehensive telemetry out of the box.
Note: Only fired nodes are represented in a workload run, so the complete workload definition may not be present in the workload run summary. This is particularly relevant for LangGraph workflows with conditional edges and branching logic—your execution reports will show actual paths taken, not all possible paths.
Compile Keyword Arguments
You can pass any LangGraph compile arguments through compile_kwargs:
- Checkpointers for persistence
- Memory configurations
- Custom compilation options
Best Practices
- Use the adapter:
LangGraphWorkloadAdapter.from_langgraph()provides comprehensive instrumentation with just a few lines of code - Initialize telemetry early: Call
initialize_telemetry()before creating your workloads - Leverage compile_kwargs: Pass checkpointers and memory configurations through the adapter
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codon_instrumentation_langgraph-0.1.0a4.tar.gz.
File metadata
- Download URL: codon_instrumentation_langgraph-0.1.0a4.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77fe78936b04c488a186b6b18e22f5d525394b94f5e16e7dca8cf5433e0ecaeb
|
|
| MD5 |
4df6235011966640a44f480d0808da54
|
|
| BLAKE2b-256 |
5ba80788d48abd144364052a50983e73e930fc3dc3e3d610cb41513d2794dcec
|
File details
Details for the file codon_instrumentation_langgraph-0.1.0a4-py3-none-any.whl.
File metadata
- Download URL: codon_instrumentation_langgraph-0.1.0a4-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae28db05aa612b0c7461ccb1e317bd26ec4cc412d331ed1b0e1d988557cfcaaf
|
|
| MD5 |
071a9961de52a844027a801111d9eab2
|
|
| BLAKE2b-256 |
b67b8723ce8ab13ea20b72df2e06b5b97bd3a161c68935487fbbb7cc94437b9c
|