Skip to navigation

Struct Observation

View as Markdown

Generated from cargo doc --no-deps -p nemo-relay -p nemo-relay-adaptive -p nemo-relay-pii-redaction -p nemo-relay-ffi -p nemo-relay-types -p nemo-relay-plugin -p nemo-relay-worker-proto -p nemo-relay-worker.

pub struct Observation<'a> {
    pub detail: DiagnosticDetailRef<'a>,
    pub count: NonZeroU64,
    pub severity: DiagnosticSeverity,
    pub outcome: DiagnosticOutcome,
    pub correlation: DiagnosticCorrelation<'a>,
    pub context: PluginObservationContext,
    /* private fields */
}

One observation. Its count is a positive input delta, never a cumulative total.

use nemo_relay::diagnostics::{Classification, Observation, SuccessCode};
// Constructors require NonZeroU64, so a zero integer is not a valid input.
let observation = Observation::new(
Classification::success(SuccessCode::SinkInitialized), "initialized", 0,
);

Fields

detail: DiagnosticDetailRef<'a>

Optional producer-approved explanation; bounding does not perform redaction.

count: NonZeroU64

Positive input occurrence delta, never a cumulative report total.

severity: DiagnosticSeverity

Operational evidence severity, independent of deployment health.

outcome: DiagnosticOutcome

Explicit observed operation outcome for summaries and windows.

correlation: DiagnosticCorrelation<'a>

Borrowed caller correlation, never an aggregate key.

context: PluginObservationContext

Plugin execution and phase names, validated before fixed-size core retention.

Implementations

impl<'a> Observation<'a>

impl<'a> Observation<'a>

new

pub fn new(
    classification: Classification,
    detail: impl Into<DiagnosticDetailRef<'a>>,
    count: NonZeroU64,
) -> Self

Author built-in evidence with severity/outcome defaults from its code.

The type guarantees a positive count; recording validates the reservation. Constructing this value does not retain its borrowed detail or source error.

extension

pub fn extension(
    handle: ExtensionHandle,
    class: Option<FailureClass>,
    outcome: DiagnosticOutcome,
    detail: impl Into<DiagnosticDetailRef<'a>>,
    count: NonZeroU64,
) -> Self

Author evidence using an admitted extension handle and supported cause.

Recording validates ownership, descriptor generation, and class. A stale handle cannot reserve a replacement code or create another counter.

extension_with_class

pub fn extension_with_class(
    handle: ExtensionHandle,
    class: ExtensionClassHandle,
    detail: impl Into<DiagnosticDetailRef<'a>>,
    count: NonZeroU64,
) -> Self

Author an extension failure with its own admitted immutable cause name. Handles from another code/registration or expired metadata are rejected.

classification_overflow

pub fn classification_overflow(
    outcome: DiagnosticOutcome,
    count: NonZeroU64,
) -> Self

Explicit summary-only admission when extension vocabulary could not fit. This is not a way to reinterpret an invalid or undeclared code.

with_plugin_context

pub fn with_plugin_context(self, context: PluginObservationContext) -> Self

Attach known plugin execution and lifecycle facts without another series.

with_outcome

pub fn with_outcome(self, outcome: DiagnosticOutcome) -> Self

Set the observed outcome without changing classification or health policy.

with_severity

pub fn with_severity(self, severity: DiagnosticSeverity) -> Self

Set output severity independently of operation outcome and cause.

with_correlation

pub fn with_correlation(self, correlation: DiagnosticCorrelation<'a>) -> Self

Attach safe borrowed correlation to be capped outside aggregate keys.

Trait Implementations

impl<'a> Clone for Observation<'a>

impl<'a> Clone for Observation<'a>

clone

fn clone(&self) -> Observation<'a>

clone_from

fn clone_from(&mut self, source: &Self)

impl<'a> Debug for Observation<'a>

impl<'a> Debug for Observation<'a>

fmt

fn fmt(&self, f: &mut Formatter<'_>) -> Result