record_event

Function record_event 

Source
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 event
  • message - Human-readable description of the event
  • attributes - Additional structured attributes as key-value pairs
  • timestamp - 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()),
);