use crate::event::payload::SupervisorEvent;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct AttemptSpan {
pub name: String,
pub sequence: u64,
pub correlation_id: String,
pub child_id: Option<String>,
}
impl AttemptSpan {
pub fn from_event(event: &SupervisorEvent) -> Self {
Self {
name: "supervisor.child_attempt".to_owned(),
sequence: event.sequence.value,
correlation_id: event.correlation_id.value.to_string(),
child_id: event
.r#where
.child_id
.as_ref()
.map(std::string::ToString::to_string),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct TracingEvent {
pub name: String,
pub sequence: u64,
pub correlation_id: String,
pub payload: String,
}
impl TracingEvent {
pub fn from_event(event: &SupervisorEvent) -> Self {
Self {
name: "supervisor.lifecycle_event".to_owned(),
sequence: event.sequence.value,
correlation_id: event.correlation_id.value.to_string(),
payload: event.what.name().to_owned(),
}
}
}