Skip to main content

ObservabilityStore

Trait ObservabilityStore 

Source
pub trait ObservabilityStore: Send + Sync {
    // Required method
    fn capture<'life0, 'life1, 'async_trait>(
        &'life0 self,
        bundle: &'life1 PayloadBundle,
    ) -> Pin<Box<dyn Future<Output = Result<CaptureResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn redactor(&self) -> &PayloadRedactor { ... }
    fn acknowledge_pii_redaction(&self) -> bool { ... }
}
Available on crate feature otel only.
Expand description

Async trait for GenAI payload capture.

Separate from MessageStore / StateStore. Called at the LLM instrumentation boundary to decide whether payloads are inlined, externalized, or omitted from spans.

Required Methods§

Source

fn capture<'life0, 'life1, 'async_trait>( &'life0 self, bundle: &'life1 PayloadBundle, ) -> Pin<Box<dyn Future<Output = Result<CaptureResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Capture or inspect the payload bundle for a single LLM operation.

Called even when the current span is non-recording (the bundle includes span_is_recording so the store can decide whether to persist externally).

§Errors

Errors are logged and swallowed — they never fail the agent run.

Provided Methods§

Source

fn redactor(&self) -> &PayloadRedactor

PII redactor applied to every payload converted for this store.

The agent loop calls this once per LLM round-trip and uses the returned redactor to mask PII in the system prompt, input messages, and output messages before building the PayloadBundle. The same masked JSON is then recorded on the OTel span, so a single redaction pass covers both external persistence and local tracing.

The default returns a shared noop redactor — existing stores keep their current byte-for-byte output. Stores that need PII-aware redaction (recommended for financial / regulated workloads) should override this with a PayloadRedactor wrapping a detector such as agent_sdk_foundation::privacy::BaselineDetector.

Source

fn acknowledge_pii_redaction(&self) -> bool

Affirm that this store has a real PII redactor installed and is safe to honour CaptureDecision::Inline.

Returns false by default. The SDK gates every Inline decision behind this method and the operator-facing OtelConfig::capture_payloads flag — both must be true for payloads to land on spans inline. Stores that have not explicitly verified their redactor MUST leave the default in place; otherwise the SDK silently drops payloads to protect against PII leakage.

CaptureDecision::Reference is not affected by this gate — externalised payloads are always recorded as references because the underlying content stays out of the span entirely.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§