Skip to main content

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

  1. Use the adapter: LangGraphWorkloadAdapter.from_langgraph() provides comprehensive instrumentation with just a few lines of code
  2. Initialize telemetry early: Call initialize_telemetry() before creating your workloads
  3. Leverage compile_kwargs: Pass checkpointers and memory configurations through the adapter

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codon_instrumentation_langgraph-0.1.0a1.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file codon_instrumentation_langgraph-0.1.0a1.tar.gz.

File metadata

File hashes

Hashes for codon_instrumentation_langgraph-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 d794453dec8c100401294d378e5f1bfd03764db1e1e1de758d9ba673db079a37
MD5 16a528569cbd342bfa8c317a0b364c3a
BLAKE2b-256 e5b6e20f0d5848ffd7f7817531080b966d97cdf93b8550f55e6b398ad014fa4a

See more details on using hashes here.

File details

Details for the file codon_instrumentation_langgraph-0.1.0a1-py3-none-any.whl.

File metadata

File hashes

Hashes for codon_instrumentation_langgraph-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 7b40bf6673ef726f95cf73e2277abb584a736ebc6fbf632ae68ef6f60b4a941c
MD5 1c57f3a9a8933c5426bc80e81ddc0ed0
BLAKE2b-256 ea79e3d1ddce36a258e28dd1d4db736e9b962acd7e6e270f61b9b0a2bca7b430

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page