pub struct TraceMetadata { /* private fields */ }Expand description
Per-pass state handed to Context::apply and
Context::cleanup.
It collects annotations for the pass’s tracing span, times steps, overrides the pass’s reported outcome, and publishes events about the resource being reconciled.
A TraceMetadata created with Default (for instance, to call a
reconciler from a unit test) accepts all of these, but reports steps and
publishes events nowhere.
Implementations§
Source§impl TraceMetadata
impl TraceMetadata
Sourcepub fn annotate<K: Display, V: Display>(&mut self, key: K, val: V)
pub fn annotate<K: Display, V: Display>(&mut self, key: K, val: V)
Adds a key/value pair to the metadata field of the pass’s
reconcile tracing span, replacing any earlier value for key.
Sourcepub fn step(&self, name: &'static str) -> Step
pub fn step(&self, name: &'static str) -> Step
Starts timing the step named name. See Step.
Step names become metric labels, so they should come from a small fixed set.
Sourcepub fn set_outcome(&mut self, outcome: Outcome)
pub fn set_outcome(&mut self, outcome: Outcome)
Overrides the outcome reported for this pass, if the reconciler
returns Ok. By default the outcome is
classified from what the reconciler returns;
an Err is always reported as Outcome::Failed.
Sourcepub async fn publish_event(&self, event: Event)
pub async fn publish_event(&self, event: Event)
Publishes event about the resource being reconciled, using the
controller’s event recorder.
Does nothing if the controller has none.
Failure to publish is logged rather than returned, since an event
only reports on reconciliation and should not change its course.
Use EventRecorder::publish directly to handle errors.
Trait Implementations§
Source§impl Debug for TraceMetadata
impl Debug for TraceMetadata
Source§impl Default for TraceMetadata
impl Default for TraceMetadata
Source§fn default() -> TraceMetadata
fn default() -> TraceMetadata
Auto Trait Implementations§
impl !RefUnwindSafe for TraceMetadata
impl !UnwindSafe for TraceMetadata
impl Freeze for TraceMetadata
impl Send for TraceMetadata
impl Sync for TraceMetadata
impl Unpin for TraceMetadata
impl UnsafeUnpin for TraceMetadata
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more