Send traces from LangGraph
Send each run of a LangGraph agent to Amiril over OpenTelemetry with OpenInference's LangChain instrumentation, in Python or TypeScript.
LangGraph does not export traces by itself. OpenInference is Arize's open-source set of OpenTelemetry instrumentations. Its LangChain instrumentation records each graph run as an OpenTelemetry trace, and an exporter sends it to Amiril.
Install
pip install openinference-instrumentation-langchain opentelemetry-sdk opentelemetry-exporter-otlp-proto-httpTurn on trace export
Run these lines once at startup, before your graph handles its first request.
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 TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
provider = TracerProvider()
provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
trace.set_tracer_provider(provider)
LangChainInstrumentor().instrument(tracer_provider=provider)Set the endpoint and key
In Amiril, create an API key and copy the endpoint:
- Switch to the environment your runs belong to, with the menu at the top of the page.
- Open Data and select Set up a new installation. It opens a panel that connects an agent to Amiril.
- In the panel, enter a Key name under Create a new key and select Create key.
- Copy the key and the OpenTelemetry traces endpoint.
Then set these variables where your agent runs:
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="<OpenTelemetry traces endpoint>"
export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="Authorization=Bearer <your API key>"Check that traces arrived
Run the agent and open Traces. The run belongs to the agent named in your code:
- With LangChain's
create_agent(createAgentin TypeScript), it is thenameyou passed there. - With a graph you built yourself, it is the
nameyou pass tocompile. Always pass one. Without it the run lands under Unattributed on the Agents page, with every other run that has no agent name.
Open the run to see each tool call with its arguments and result, and each model call.
A new run shows a Scoring badge until Amiril has ranked it. If no run appears, read what the exporter logged.
Next steps
Find a run and see why it was flagged
Open a run from an issue, the Anomalies page or the Traces page and see why Amiril flagged it. Then review it to teach Amiril which rarity factors are noise.
Add Amiril to a LangGraph agent
Check every tool call of a LangGraph agent built with create_agent against your rules, in Python or TypeScript, and block the calls that break one.
Set up environments and API keys
Create an environment such as Staging and an API key that sends to it, so test runs stay out of production. Then put the key where each service runs.
Send traces from Google ADK
Turn on Google ADK's own OpenTelemetry tracing in Python or TypeScript and send every agent invocation to Amiril, with each tool call's arguments and result.
Send traces from CrewAI
Send each CrewAI kickoff to Amiril as one run over OpenTelemetry with OpenInference, including every agent's tool calls and the model calls made to OpenAI.
Last updated on