Skip to main content

Crate lc_observability

Crate lc_observability 

Source
Expand description

Pluggable observability sinks for LangChainRust.

The framework exposes the MetricsSink interface and an ObsEvent payload from lc-core (written by TokenTrackingLLM and AgentExecutor). This crate ships concrete sinks that implement it:

  • JsonLinesSink (default jsonl feature): append each event as one JSON line to a file.
  • MongoSink (mongodb feature): insert each event as a document.

Export failures are returned as ObsError; the framework logs a warn and the main flow continues — sinks never interrupt the agent.

Structs§

JsonLinesSink
Appends each event as a single JSON line to a file (one record per line — tail-able, jq-parseable, replayable). The file is opened once in append mode at construction, so concurrent exports serialize through the mutex.
MongoSink
Inserts each event as one document into the given collection. Records keep the serde tag ("kind"), so a single collection can hold token-usage and agent metrics side by side.

Enums§

ObsError
Export error. Implementations surface failures through this and the framework layer only logs a warn — it never propagates into the main flow.
ObsEvent
One observability record (the unified export payload).

Traits§

MetricsSink
Pluggable observability sink. The framework only provides the interface and binds no concrete plugin.