opentelemetry::logs

Trait LogRecord

Source
pub trait LogRecord {
    // Required methods
    fn set_event_name(&mut self, name: &'static str);
    fn set_target<T>(&mut self, _target: T)
       where T: Into<Cow<'static, str>>;
    fn set_timestamp(&mut self, timestamp: SystemTime);
    fn set_observed_timestamp(&mut self, timestamp: SystemTime);
    fn set_severity_text(&mut self, text: &'static str);
    fn set_severity_number(&mut self, number: Severity);
    fn set_body(&mut self, body: AnyValue);
    fn add_attributes<I, K, V>(&mut self, attributes: I)
       where I: IntoIterator<Item = (K, V)>,
             K: Into<Key>,
             V: Into<AnyValue>;
    fn add_attribute<K, V>(&mut self, key: K, value: V)
       where K: Into<Key>,
             V: Into<AnyValue>;

    // Provided method
    fn set_trace_context(
        &mut self,
        trace_id: TraceId,
        span_id: SpanId,
        trace_flags: Option<TraceFlags>,
    ) { ... }
}
Available on crate feature logs only.
Expand description

SDK implemented trait for managing log records

Required Methods§

Source

fn set_event_name(&mut self, name: &'static str)

Sets the event_name of a record

Source

fn set_target<T>(&mut self, _target: T)
where T: Into<Cow<'static, str>>,

Sets the target of a record. Currently, both opentelemetry-appender-tracing and opentelemetry-appender-log create a single logger with a scope that doesn’t accurately reflect the component emitting the logs. Exporters MAY use this field to override the instrumentation_scope.name.

Source

fn set_timestamp(&mut self, timestamp: SystemTime)

Sets the time when the event occurred measured by the origin clock, i.e. the time at the source.

Source

fn set_observed_timestamp(&mut self, timestamp: SystemTime)

Sets the observed event timestamp.

Source

fn set_severity_text(&mut self, text: &'static str)

Sets severity as text.

Source

fn set_severity_number(&mut self, number: Severity)

Sets severity as a numeric value.

Source

fn set_body(&mut self, body: AnyValue)

Sets the message body of the log.

Source

fn add_attributes<I, K, V>(&mut self, attributes: I)
where I: IntoIterator<Item = (K, V)>, K: Into<Key>, V: Into<AnyValue>,

Adds multiple attributes.

Source

fn add_attribute<K, V>(&mut self, key: K, value: V)
where K: Into<Key>, V: Into<AnyValue>,

Adds a single attribute.

Provided Methods§

Source

fn set_trace_context( &mut self, trace_id: TraceId, span_id: SpanId, trace_flags: Option<TraceFlags>, )

Available on crate feature trace only.

Sets the trace context of the log.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§