OpenInference's LangChain instrumentation turns LangChain and LangGraph runs into OpenTelemetry spans. Export them to Maple, pass the conversation's thread_id on every call, and each chat becomes one agent session. Python is shown here; the full guide covers TypeScript too.
pip install "langchain>=1.4" "langgraph>=1.2" "langchain-openai>=1.6" \
"openinference-instrumentation-langchain>=0.1.76" "openinference-instrumentation>=0.1.66" \
"opentelemetry-sdk>=1.45" "opentelemetry-exporter-otlp-proto-http>=1.45" export OTEL_SERVICE_NAME=support-agent
export OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=production
export OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.maple.dev
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer YOUR_INGEST_KEY" # tracing.py
from openinference.instrumentation import TraceConfig
from openinference.instrumentation.langchain import LangChainInstrumentor
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import SpanProcessor, TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
# Marks agent and tool-node spans, which Maple draws as agent lanes and steps.
# The name= you gave create_agent(), and graph nodes that act as agents
AGENT_NAMES = {"assistant"}
# Your tool node
STEP_NAMES = {"tools"}
class AgentSpans(SpanProcessor):
def on_start(self, span, parent_context=None):
if span.instrumentation_scope.name != "openinference.instrumentation.langchain":
return
if span.name in AGENT_NAMES:
span.set_attribute("gen_ai.operation.name", "invoke_agent")
span.set_attribute("gen_ai.agent.name", span.name)
elif span.name in STEP_NAMES:
span.set_attribute("gen_ai.operation.name", "invoke_workflow")
provider = TracerProvider()
provider.add_span_processor(AgentSpans())
provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
trace.set_tracer_provider(provider)
LangChainInstrumentor().instrument(
tracer_provider=provider,
config=TraceConfig(enable_genai_semconv=True),
) import tracing # first, before the first invoke()
result = agent.invoke(
{"messages": [{"role": "user", "content": text}]},
{"configurable": {"thread_id": conversation_id}},
) This is the short path. The full LangChain guide covers the rest.
Organization in the EU region? Send to https://ingest.eu.maple.dev instead of https://ingest.maple.dev. An ingest key only works in its own region.
What you get
Every invoke() with the same thread_id is a turn in one agent session. LangGraph Server threads group without extra code.
Each agent named in AGENT_NAMES, sub-agents included, gets its own lane in the session.
Each chat model call is a span with the model, the messages and the input and output token counts.
Tool spans are named after your tools and carry the arguments and the result.
Nodes such as your tool node show as workflow steps, so a turn reads in the order the graph ran.
With enable_genai_semconv, each turn shows the messages that went in and the reply that came out, so a session reads like the chat did.
A chain with no graph, such as prompt | model, drops the configurable thread_id. Pass it as metadata instead, or every message becomes its own session.
With a custom base_url, vLLM or a gateway, set stream_usage=True on ChatOpenAI. Without it, streamed replies carry no token counts.
If every model call appears twice, remove LANGSMITH_OTEL_ENABLED and any provider instrumentor such as openinference-instrumentation-openai.
Integrations
Add the SDK, point your OTLP exporter at Maple, and traces arrive.
maple.dev: observability on OpenTelemetry