Langfuse is the default production observability backend for Cognis. TheDocumentation Index
Fetch the complete documentation index at: https://cognis.vasanth.xyz/llms.txt
Use this file to discover all available pages before exploring further.
cognis-trace crate ships a TracingHandler that translates Cognis runtime events into Langfuse spans, generations, and scores — including token usage, USD cost, prompts, and trace metadata. Three steps and you’re shipping data.
Step 1 — Add the dependency
Step 2 — Set credentials
Step 3 — Build a TracingHandler
Step 4 — Attach to your runs
TracingHandler implements CallbackHandler. Wrap it with HandlerObserver to use it on a RunnableConfig:
Step 5 — Drain on shutdown
TracingHandler runs background batchers per exporter so a slow Langfuse never blocks your hot path. Before the process exits, drain them:
Trace metadata
Set session / user / release / environment so traces are filterable in the Langfuse UI:Multiple exporters
Stack stdout (for local logs) and Langfuse (for production) on the same handler:handler.stats(name).
How it works
TracingHandleris aCallbackHandler. Lifecycle hooks turn into Langfuse spans (chains, tools, retrievers) and generations (LLM calls).- Token usage and cost are computed automatically.
with_default_pricing()loads a 2026-05 snapshot for the major providers; override withoverride_pricefor negotiated rates. - Trace nesting follows
parent_run_id. Every Cognis composition site already propagates this — sub-runs nest correctly. - Batching keeps the hot path fast. No blocking HTTP in
on_llm_end. Slow Langfuse → batches accumulate → emergency dropping (logged) before they OOM.
Beyond traces
cognis-trace also surfaces:
- Cost details — see Cost tracking.
- Versioned prompts pulled from Langfuse — see Prompts and scores.
- Evaluation scores submitted back to Langfuse — see Evaluation.
What about OpenTelemetry?
OpenTelemetry support is on the roadmap. Until it ships, implementTraceExporter (it’s a thin async trait) and forward to your OTel collector — the batching infrastructure is already there, you only write the format conversion. The same path works for any other observability backend you’d want to send spans to.
See also
Cost tracking
USD cost per request from a price table.
Prompts and scores
Versioned prompts and eval scores.
Callbacks and observers
The lower-level interface.