pub struct InMemoryLogExporter { /* private fields */ }Expand description
An in-memory logs exporter that stores logs data in memory..
This exporter is useful for testing and debugging purposes.
It stores logs in a Vec<OwnedLogData>. Logs can be retrieved using
get_emitted_logs method.
§Example
// Create an InMemoryLogExporter
let exporter: InMemoryLogExporter = InMemoryLogExporter::default();
//Create a LoggerProvider and register the exporter
let logger_provider = SdkLoggerProvider::builder()
.with_log_processor(BatchLogProcessor::builder(exporter.clone()).build())
.build();
// Setup Log Appenders and emit logs. (Not shown here)
logger_provider.force_flush();
let emitted_logs = exporter.get_emitted_logs().unwrap();
for log in emitted_logs {
println!("{:?}", log);
}Implementations§
Source§impl InMemoryLogExporter
impl InMemoryLogExporter
Sourcepub fn is_shutdown_called(&self) -> bool
pub fn is_shutdown_called(&self) -> bool
Returns true if shutdown was called.
Sourcepub fn get_emitted_logs(
&self,
) -> Result<Vec<LogDataWithResource>, InMemoryExporterError>
pub fn get_emitted_logs( &self, ) -> Result<Vec<LogDataWithResource>, InMemoryExporterError>
Returns the logs emitted via Logger as a vector of LogDataWithResource.
§Example
use opentelemetry_sdk::logs::{InMemoryLogExporter, InMemoryLogExporterBuilder};
let exporter = InMemoryLogExporterBuilder::default().build();
let emitted_logs = exporter.get_emitted_logs().unwrap();Trait Implementations§
Source§impl Clone for InMemoryLogExporter
impl Clone for InMemoryLogExporter
Source§fn clone(&self) -> InMemoryLogExporter
fn clone(&self) -> InMemoryLogExporter
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InMemoryLogExporter
impl Debug for InMemoryLogExporter
Source§impl Default for InMemoryLogExporter
impl Default for InMemoryLogExporter
Source§impl LogExporter for InMemoryLogExporter
impl LogExporter for InMemoryLogExporter
Source§async fn export(&self, batch: LogBatch<'_>) -> OTelSdkResult
async fn export(&self, batch: LogBatch<'_>) -> OTelSdkResult
Exports a batch of log records and their associated instrumentation scopes. Read more
Source§fn shutdown_with_timeout(&self, _timeout: Duration) -> OTelSdkResult
fn shutdown_with_timeout(&self, _timeout: Duration) -> OTelSdkResult
Shuts down the exporter.
Source§fn set_resource(&mut self, resource: &Resource)
fn set_resource(&mut self, resource: &Resource)
Set the resource for the exporter.
Source§fn shutdown(&self) -> OTelSdkResult
fn shutdown(&self) -> OTelSdkResult
Shuts down the exporter with a default timeout.
Auto Trait Implementations§
impl Freeze for InMemoryLogExporter
impl RefUnwindSafe for InMemoryLogExporter
impl Send for InMemoryLogExporter
impl Sync for InMemoryLogExporter
impl Unpin for InMemoryLogExporter
impl UnwindSafe for InMemoryLogExporter
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