pub struct EventMeta {
pub event_id: String,
pub occurred_at: DateTime<Utc>,
pub trace_id: Option<String>,
}Expand description
Metadata attached to every metrics event.
This structure provides common identification and timing information that is shared across all event types in the metrics system. Metadata attached to every metrics event.
This structure provides common identification and timing information that is shared across all event types in the metrics system.
§Fields
event_id: Unique identifier for this event (UUID v4 format)occurred_at: UTC timestamp when the event occurredtrace_id: Optional identifier for correlating related events across services
§Example
// Create event metadata without trace ID
let meta = EventMeta::new();
assert!(!meta.event_id.is_empty());
assert!(meta.trace_id.is_none());
// Create event metadata with trace ID for distributed tracing
let traced_meta = EventMeta::with_trace_id("req-abc-123");
assert_eq!(traced_meta.trace_id, Some("req-abc-123".to_string()));Fields§
§event_id: StringUnique event ID (UUID v4)
occurred_at: DateTime<Utc>When the event occurred
trace_id: Option<String>Optional trace ID for correlating request chains
Implementations§
Source§impl EventMeta
impl EventMeta
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates new event metadata with a fresh UUID and current timestamp.
The trace ID is set to None. Use this constructor when you don’t need
to correlate this event with other events across service boundaries.
§Example
use bamboo_agent::agent::metrics::events::EventMeta;
let meta = EventMeta::new();
assert!(!meta.event_id.is_empty());
assert!(meta.trace_id.is_none());Sourcepub fn with_trace_id(trace_id: impl Into<String>) -> Self
pub fn with_trace_id(trace_id: impl Into<String>) -> Self
Creates new event metadata with a trace ID for distributed request tracing.
Use this constructor when you need to correlate this event with other events that are part of the same logical request or operation flow.
§Arguments
trace_id- A unique identifier for the request chain (will be converted to String)
§Example
use bamboo_agent::agent::metrics::events::EventMeta;
let meta = EventMeta::with_trace_id("req-12345");
assert_eq!(meta.trace_id, Some("req-12345".to_string()));