Skip to main content

AuditConfig

Struct AuditConfig 

Source
pub struct AuditConfig {
Show 14 fields pub enabled: bool, pub record_attempts: bool, pub record_retries: bool, pub record_success: bool, pub record_failure: bool, pub record_cancellation: bool, pub record_timing: bool, pub record_normalization: bool, pub include_profile: bool, pub include_sdk_request_id: bool, pub include_provider_request_id: bool, pub include_session_id: bool, pub include_usage: bool, pub sample_every: u64,
}
Expand description

Controls which structured transport events are emitted.

Audit events never contain prompts, messages, reasoning, tool arguments, tool results, request bodies, or response bodies. Correlation identifiers and profile metadata require explicit opt-in.

Fields§

§enabled: bool

Master switch: when false, no audit events are emitted.

§record_attempts: bool§record_retries: bool

Emit retry and stream-reconnect scheduling events.

§record_success: bool

Emit success outcomes for attempts and requests.

§record_failure: bool

Emit failure outcomes for attempts and requests.

§record_cancellation: bool

Emit a final AuditEvent::RequestFinished with outcome AuditOutcome::Cancelled when a stream is dropped before completion.

§record_timing: bool

Emit response-header and first-token timing events.

§record_normalization: bool

Emit context-free aggregate counts for normalization repairs.

§include_profile: bool

Include the profile snapshot in AuditEvent::RequestStarted.

§include_sdk_request_id: bool

Include the caller-supplied SDK request id in AuditEvent::RequestStarted.

§include_provider_request_id: bool

Include the provider’s request id in header, attempt, and completion events.

§include_session_id: bool

Include the session id in AuditEvent::RequestStarted. Off by default because session ids can be tenant-sensitive.

§include_usage: bool

Include token usage in AuditEvent::RequestFinished.

§sample_every: u64

Sample one out of every N logical requests. 1 records every request.

Implementations§

Source§

impl AuditConfig

Source

pub fn enabled() -> Self

Creates a config with auditing enabled and all other defaults kept.

Source

pub fn record_attempts(self, enabled: bool) -> Self

Sets whether attempt-level events are emitted.

Source

pub fn record_retries(self, enabled: bool) -> Self

Sets whether retry and reconnect scheduling events are emitted.

Source

pub fn record_success(self, enabled: bool) -> Self

Sets whether success outcomes are emitted.

Source

pub fn record_failure(self, enabled: bool) -> Self

Sets whether failure outcomes are emitted.

Source

pub fn record_cancellation(self, enabled: bool) -> Self

Emit a final event when a stream is dropped before terminal completion.

Source

pub fn record_timing(self, enabled: bool) -> Self

Emit response-header and first-token timing events.

Source

pub fn record_normalization(self, enabled: bool) -> Self

Emit context-free aggregate counts for normalization repairs.

Source

pub fn include_profile(self, enabled: bool) -> Self

Include the selected profile id, model-profile flag, and capability snapshot in RequestStarted.

Source

pub fn include_sdk_request_id(self, enabled: bool) -> Self

Sets whether the SDK request id is included in AuditEvent::RequestStarted.

Source

pub fn include_provider_request_id(self, enabled: bool) -> Self

Sets whether the provider request id is included in events.

Source

pub fn include_session_id(self, enabled: bool) -> Self

Session IDs can be tenant-sensitive. They are excluded by default.

Source

pub fn include_usage(self, enabled: bool) -> Self

Sets whether token usage is included in AuditEvent::RequestFinished.

Source

pub fn sample_every(self, sample_every: u64) -> Self

Sets the sampling rate; values below 1 are clamped to 1.

Trait Implementations§

Source§

impl Clone for AuditConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for AuditConfig

Source§

impl Debug for AuditConfig

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for AuditConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for AuditConfig

Source§

impl PartialEq for AuditConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AuditConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more