pub struct Observation<T>where
T: Observable,{
pub version: SchemaVersion,
pub timestamp: Timestamp,
pub service: ServiceName,
pub identity: ProcessIdentity,
pub trace: Option<TraceContext>,
pub payload: T,
}Expand description
Shared envelope around a typed observation payload.
Fields§
§version: SchemaVersionEnvelope schema version.
timestamp: TimestampUTC observation timestamp.
service: ServiceNameService that emitted the observation.
identity: ProcessIdentityProcess identity attached to the observation.
trace: Option<TraceContext>Optional trace context for correlation.
payload: TCaller-owned typed payload.
Implementations§
Source§impl<T> Observation<T>where
T: Observable,
impl<T> Observation<T>where
T: Observable,
Sourcepub fn new(service: ServiceName, payload: T) -> Self
pub fn new(service: ServiceName, payload: T) -> Self
Creates a new observation envelope using the current UTC timestamp.
§Examples
use sc_observability_types::{Observation, ServiceName};
let observation = Observation::new(
ServiceName::new("demo").expect("valid service"),
"payload".to_string(),
);
assert_eq!(observation.service.as_str(), "demo");
assert_eq!(observation.version.as_str(), "v1");Trait Implementations§
Source§impl<T> Clone for Observation<T>where
T: Observable + Clone,
impl<T> Clone for Observation<T>where
T: Observable + Clone,
Source§fn clone(&self) -> Observation<T>
fn clone(&self) -> Observation<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for Observation<T>where
T: Observable + Debug,
impl<T> Debug for Observation<T>where
T: Observable + Debug,
Source§impl<'de, T> Deserialize<'de> for Observation<T>where
T: Observable + Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Observation<T>where
T: Observable + Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> PartialEq for Observation<T>where
T: Observable + PartialEq,
impl<T> PartialEq for Observation<T>where
T: Observable + PartialEq,
Source§impl<T> Serialize for Observation<T>where
T: Observable + Serialize,
impl<T> Serialize for Observation<T>where
T: Observable + Serialize,
impl<T> StructuralPartialEq for Observation<T>where
T: Observable,
Auto Trait Implementations§
impl<T> Freeze for Observation<T>where
T: Freeze,
impl<T> RefUnwindSafe for Observation<T>where
T: RefUnwindSafe,
impl<T> Send for Observation<T>
impl<T> Sync for Observation<T>
impl<T> Unpin for Observation<T>where
T: Unpin,
impl<T> UnsafeUnpin for Observation<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Observation<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more