Struct SimpleLogProcessor
pub struct SimpleLogProcessor<T>where
T: LogExporter,{ /* private fields */ }Expand description
A LogProcessor designed for testing and debugging purpose, that immediately
exports log records as they are emitted. Log records are exported synchronously
in the same thread that emits the log record.
When using this processor with the OTLP Exporter, the following exporter
features are supported:
grpc-tonic: This requires LoggerProvider to be created within a tokio runtime. Logs can be emitted from any thread, including tokio runtime threads.reqwest-blocking-client: LoggerProvider may be created anywhere, but logs must be emitted from a non-tokio runtime thread.reqwest-client: LoggerProvider may be created anywhere, but logs must be emitted from a tokio runtime thread.
§Example
§Using a SimpleLogProcessor
use opentelemetry_sdk::logs::{SimpleLogProcessor, SdkLoggerProvider, LogExporter};
use opentelemetry::global;
use opentelemetry_sdk::logs::InMemoryLogExporter;
let exporter = InMemoryLogExporter::default(); // Replace with an actual exporter
let provider = SdkLoggerProvider::builder()
.with_simple_exporter(exporter)
.build();
Implementations§
§impl<T> SimpleLogProcessor<T>where
T: LogExporter,
impl<T> SimpleLogProcessor<T>where
T: LogExporter,
pub fn new(exporter: T) -> SimpleLogProcessor<T>
pub fn new(exporter: T) -> SimpleLogProcessor<T>
Creates a new instance of SimpleLogProcessor.
Trait Implementations§
§impl<T> Debug for SimpleLogProcessor<T>where
T: Debug + LogExporter,
impl<T> Debug for SimpleLogProcessor<T>where
T: Debug + LogExporter,
§impl<T> LogProcessor for SimpleLogProcessor<T>where
T: LogExporter,
impl<T> LogProcessor for SimpleLogProcessor<T>where
T: LogExporter,
§fn emit(
&self,
record: &mut SdkLogRecord,
instrumentation: &InstrumentationScope,
)
fn emit( &self, record: &mut SdkLogRecord, instrumentation: &InstrumentationScope, )
Called when a log record is ready to processed and exported. Read more
§fn force_flush(&self) -> Result<(), OTelSdkError>
fn force_flush(&self) -> Result<(), OTelSdkError>
Force the logs lying in the cache to be exported.
§fn shutdown(&self) -> Result<(), OTelSdkError>
fn shutdown(&self) -> Result<(), OTelSdkError>
Shuts down the processor with default timeout.
§fn set_resource(&mut self, resource: &Resource)
fn set_resource(&mut self, resource: &Resource)
Set the resource for the log processor.
§fn shutdown_with_timeout(&self, _timeout: Duration) -> Result<(), OTelSdkError>
fn shutdown_with_timeout(&self, _timeout: Duration) -> Result<(), OTelSdkError>
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.
Auto Trait Implementations§
impl<T> !Freeze for SimpleLogProcessor<T>
impl<T> RefUnwindSafe for SimpleLogProcessor<T>
impl<T> Send for SimpleLogProcessor<T>
impl<T> Sync for SimpleLogProcessor<T>
impl<T> Unpin for SimpleLogProcessor<T>where
T: Unpin,
impl<T> UnwindSafe for SimpleLogProcessor<T>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Create a new
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more