pub fn record_event(
level: EventLevel,
message: impl AsRef<str>,
attributes: Vec<KeyValue>,
timestamp: Option<SystemTime>,
)Expand description
Record a structured event within the current OpenTelemetry span (function-based API).
This is the direct function interface for recording events. For a more ergonomic
builder-based API, see the event() function.
§Arguments
level- The severity level of the eventmessage- Human-readable description of the eventattributes- Additional structured attributes as key-value pairstimestamp- Optional custom timestamp (uses current time if None)
§Examples
use lambda_otel_lite::events::{record_event, EventLevel};
use opentelemetry::KeyValue;
// Simple event
record_event(
EventLevel::Info,
"User logged in",
vec![],
None,
);
// Event with attributes and custom timestamp
record_event(
EventLevel::Warn,
"Rate limit approaching",
vec![
KeyValue::new("user_id", "123"),
KeyValue::new("requests_remaining", 10),
],
Some(std::time::SystemTime::now()),
);