agentsentriopen-source LLM observabilityDashboard

guide

Instrument your app

Point the stack you already use at AgentSentri. Every recipe ends the same way: spans arrive over OTLP, and anything carrying gen_ai.* attributes lands as a generation with model, tokens, and computed USD cost.

The two lines every recipe shares

The OTLP endpoint accepts the default protobuf encoding (and JSON), so a stock exporter needs no protocol override:

export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="$HOST/api/public/otel/v1/traces"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="Authorization=Bearer sk-as-..."

GenAI instrumentations do not capture prompt/completion content by default — each recipe notes its opt-in.

The recipes

  1. 1.OpenAI SDK (Python)

    The official OpenTelemetry contrib instrumentation patches the openai client and emits gen_ai.* spans — zero code changes. Prompt/completion content is off by default; the env var opts in.

    pip install opentelemetry-distro opentelemetry-exporter-otlp-proto-http \
                opentelemetry-instrumentation-openai-v2
    export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true
    opentelemetry-instrument python app.py
  2. 2.Vercel AI SDK (TypeScript)

    Telemetry is built in — register any OTel Node setup with an OTLP exporter (the exporter reads the two env vars), then enable it per call.

    new NodeSDK({ traceExporter: new OTLPTraceExporter() }).start();
    
    const { text } = await generateText({
      model: anthropic("claude-sonnet-5"),
      prompt: "…",
      experimental_telemetry: { isEnabled: true },
    });
  3. 3.Anthropic SDK — or any client

    No auto-instrumentation needed: wrap the call with the AgentSentri SDK and report usage yourself. Same pattern for custom in-house clients; prefer wrap() (TS) or @observe (Python) for whole functions with automatic nesting.

    const gen = trace.generation("chat", { model: "claude-sonnet-5" });
    gen.setInput({ messages });
    const msg = await anthropic.messages.create({ model, max_tokens: 1024, messages });
    gen.setOutput(msg.content);
    gen.setUsage({
      inputTokens: msg.usage.input_tokens,
      outputTokens: msg.usage.output_tokens,
    });
    gen.end();
  4. 4.LangChain / LangGraph

    Community OpenTelemetry instrumentations (the OpenLLMetry and OpenInference families) patch LangChain to emit OTel spans — install one, register an OTLP exporter, set the two env vars. Chains arrive as nested spans, model calls as generations. Or skip the dependency and wrap() chain.invoke with the AgentSentri SDK.

    # e.g. OpenLLMetry's instrumentation (check its docs for content flags):
    pip install opentelemetry-instrumentation-langchain
    # register an OTLP exporter + the two env vars above — that's the whole recipe.
    
    # no-dependency alternative: wrap invocations with the AgentSentri SDK
    answer = observed_invoke({"question": q})   # @observe-wrapped chain.invoke

Group related traces into sessions

Set the OpenTelemetry session.id attribute on related spans. AgentSentri falls back to gen_ai.conversation.id when session.id is absent. Use an opaque correlation token — never an email address, prompt, or other personal data.

span.setAttribute("session.id", "chat_01JABC...");

Verifying it worked

Send one request, open the project's Traces tab, and look for a generation row with model + tokens + cost. Send two related traces and open the Sessions tab to verify chronological replay. Nothing arriving?

401 in exporter logsHeader syntax is Authorization=Bearer sk-as-... (note the =).
415 responsesPre-protobuf AgentSentri — upgrade, or set OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/json.
Spans but no generationsNo gen_ai.* attributes — the span lands as a plain SPAN; check the instrumentation's semconv/content flags.
No costModel not in the pricing snapshot; tokens still record, or send costUsd yourself via the SDK.