Skip to content

DOCS

LangGraph and LangChain

LangGraph runs nodes through LangChain callbacks. An OpenTelemetry instrumentor on that callback path sees the graph, the model, and the tools. Monitor also accepts traceloop.span.kind values agent, workflow, tool, generation, and llm.

  1. Create an ingest key.
  2. Install opentelemetry-sdk, opentelemetry-exporter-otlp-proto-http, and opentelemetry-instrumentation-langchain.
  3. Point OTEL_EXPORTER_OTLP_TRACES_ENDPOINT at https://balerxgate.com/v1/traces. This variable is the full traces URL. The base variable OTEL_EXPORTER_OTLP_ENDPOINT is a host, and the SDK appends /v1/traces itself.
  4. Set OTEL_EXPORTER_OTLP_HEADERS to x-balerx-key=YOUR_INGEST_KEY.
  5. Call LangchainInstrumentor().instrument() before you compile or invoke the graph.
  6. Invoke the graph once and look at Runs.
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://balerxgate.com/v1/traces
export OTEL_EXPORTER_OTLP_HEADERS=x-balerx-key=YOUR_INGEST_KEY
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.instrumentation.langchain import LangchainInstrumentor
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.trace import set_tracer_provider

provider = TracerProvider()
provider.add_span_processor(
    BatchSpanProcessor(OTLPSpanExporter(), max_export_batch_size=512)
)
set_tracer_provider(provider)
LangchainInstrumentor().instrument()

OTLPSpanExporter() with no arguments reads the environment from step 3. Prompts stay out of Balerx until content capture is enabled.