Trait LogProcessor

Source
pub trait LogProcessor:
    Send
    + Sync
    + Debug {
    // Required methods
    fn emit(
        &self,
        data: &mut SdkLogRecord,
        instrumentation: &InstrumentationScope,
    );
    fn force_flush(&self) -> OTelSdkResult;

    // Provided methods
    fn shutdown_with_timeout(&self, _timeout: Duration) -> OTelSdkResult { ... }
    fn shutdown(&self) -> OTelSdkResult { ... }
    fn event_enabled(
        &self,
        _level: Severity,
        _target: &str,
        _name: Option<&str>,
    ) -> bool { ... }
    fn set_resource(&mut self, _resource: &Resource) { ... }
}
Expand description

The interface for plugging into a SdkLogger.

Required Methods§

Source

fn emit(&self, data: &mut SdkLogRecord, instrumentation: &InstrumentationScope)

Called when a log record is ready to processed and exported.

This method receives a mutable reference to LogRecord. If the processor needs to handle the export asynchronously, it should clone the data to ensure it can be safely processed without lifetime issues. Any changes made to the log data in this method will be reflected in the next log processor in the chain.

§Parameters
  • record: A mutable reference to LogRecord representing the log record.
  • instrumentation: The instrumentation scope associated with the log record.
Source

fn force_flush(&self) -> OTelSdkResult

Force the logs lying in the cache to be exported.

Provided Methods§

Source

fn shutdown_with_timeout(&self, _timeout: Duration) -> OTelSdkResult

Shuts down the processor. After shutdown returns the log processor should stop processing any logs. It’s up to the implementation on when to drop the LogProcessor.

Source

fn shutdown(&self) -> OTelSdkResult

Shuts down the processor with default timeout.

Source

fn event_enabled( &self, _level: Severity, _target: &str, _name: Option<&str>, ) -> bool

Check if logging is enabled

Source

fn set_resource(&mut self, _resource: &Resource)

Set the resource for the log processor.

Implementors§