pub struct LogRecord {
pub timestamp: i64,
pub observed_timestamp: Option<i64>,
pub severity: SeverityLevel,
pub severity_text: Option<String>,
pub body: String,
pub attributes: HashMap<String, String>,
pub trace_id: Option<String>,
pub span_id: Option<String>,
pub resource: Option<Resource>,
}Expand description
Represents a log record
Fields§
§timestamp: i64Timestamp in nanoseconds since Unix epoch
observed_timestamp: Option<i64>Observed timestamp (when the event was observed)
severity: SeverityLevelSeverity level
severity_text: Option<String>Severity text (human-readable)
body: StringLog body/message
attributes: HashMap<String, String>Log attributes
trace_id: Option<String>Trace ID (if part of a trace)
span_id: Option<String>Span ID (if part of a span)
resource: Option<Resource>Associated resource
Implementations§
Source§impl LogRecord
impl LogRecord
Sourcepub fn new(
severity: SeverityLevel,
body: impl Into<String>,
timestamp: i64,
) -> Self
pub fn new( severity: SeverityLevel, body: impl Into<String>, timestamp: i64, ) -> Self
Create a new log record
Sourcepub fn with_attribute(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_attribute( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add an attribute to the log record
Sourcepub fn with_trace_context(self, trace_id: String, span_id: String) -> Self
pub fn with_trace_context(self, trace_id: String, span_id: String) -> Self
Set the trace context
Sourcepub fn with_resource(self, resource: Resource) -> Self
pub fn with_resource(self, resource: Resource) -> Self
Set the resource for the log record
Trait Implementations§
Source§impl<'de> Deserialize<'de> for LogRecord
impl<'de> Deserialize<'de> for LogRecord
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
impl StructuralPartialEq for LogRecord
Auto Trait Implementations§
impl Freeze for LogRecord
impl RefUnwindSafe for LogRecord
impl Send for LogRecord
impl Sync for LogRecord
impl Unpin for LogRecord
impl UnsafeUnpin for LogRecord
impl UnwindSafe for LogRecord
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