Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,12 @@ impl MetricReader for BoxedMetricReader {

/// Boxed log processor for dynamic dispatch
#[derive(Debug)]
pub(crate) struct BoxedLogProcessor {
inner: Box<dyn LogProcessor + Send + Sync>,
}
pub(crate) struct BoxedLogProcessor(Box<dyn LogProcessor + Send + Sync>);

impl BoxedLogProcessor {
/// Create a new boxed log processor.
pub fn new(processor: Box<dyn LogProcessor + Send + Sync>) -> Self {
Self { inner: processor }
Self(processor)
}
}

Expand All @@ -422,15 +420,26 @@ impl LogProcessor for BoxedLogProcessor {
log_record: &mut opentelemetry_sdk::logs::SdkLogRecord,
instrumentation_scope: &opentelemetry::InstrumentationScope,
) {
self.inner.emit(log_record, instrumentation_scope);
self.0.emit(log_record, instrumentation_scope);
}

fn force_flush(&self) -> opentelemetry_sdk::error::OTelSdkResult {
self.inner.force_flush()
self.0.force_flush()
}

fn shutdown_with_timeout(
&self,
timeout: std::time::Duration,
) -> opentelemetry_sdk::error::OTelSdkResult {
self.0.shutdown_with_timeout(timeout)
}

fn shutdown(&self) -> opentelemetry_sdk::error::OTelSdkResult {
self.inner.shutdown()
self.0.shutdown()
}

fn set_resource(&mut self, resource: &opentelemetry_sdk::Resource) {
self.0.set_resource(resource);
}
}

Expand Down
28 changes: 17 additions & 11 deletions tests/test_basic_exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::sync::Arc;

use insta::assert_debug_snapshot;
use opentelemetry::KeyValue;
use opentelemetry_sdk::{
Resource,
logs::{InMemoryLogExporter, SimpleLogProcessor},
Expand Down Expand Up @@ -49,7 +50,12 @@ fn test_basic_span() {
.with_advanced_options(
AdvancedOptions::default()
.with_id_generator(DeterministicIdGenerator::new())
.with_log_processor(SimpleLogProcessor::new(log_exporter.clone())),
.with_log_processor(SimpleLogProcessor::new(log_exporter.clone()))
.with_resource(
Resource::builder_empty()
.with_attribute(KeyValue::new("resource.key", "value"))
.build(),
),
)
.finish()
.unwrap();
Expand Down Expand Up @@ -120,7 +126,7 @@ fn test_basic_span() {
"code.lineno",
),
value: I64(
27,
32,
),
},
KeyValue {
Expand Down Expand Up @@ -246,7 +252,7 @@ fn test_basic_span() {
"code.lineno",
),
value: I64(
28,
33,
),
},
KeyValue {
Expand Down Expand Up @@ -402,7 +408,7 @@ fn test_basic_span() {
"code.lineno",
),
value: I64(
28,
33,
),
},
KeyValue {
Expand Down Expand Up @@ -564,7 +570,7 @@ fn test_basic_span() {
"code.lineno",
),
value: I64(
29,
34,
),
},
KeyValue {
Expand Down Expand Up @@ -700,7 +706,7 @@ fn test_basic_span() {
"code.lineno",
),
value: I64(
29,
34,
),
},
KeyValue {
Expand Down Expand Up @@ -842,7 +848,7 @@ fn test_basic_span() {
"code.lineno",
),
value: I64(
30,
35,
),
},
KeyValue {
Expand Down Expand Up @@ -978,7 +984,7 @@ fn test_basic_span() {
"code.lineno",
),
value: I64(
30,
35,
),
},
KeyValue {
Expand Down Expand Up @@ -1120,7 +1126,7 @@ fn test_basic_span() {
"code.lineno",
),
value: I64(
27,
32,
),
},
KeyValue {
Expand Down Expand Up @@ -1292,7 +1298,7 @@ fn test_basic_span() {
"code.lineno",
),
Int(
31,
36,
),
),
),
Expand Down Expand Up @@ -1459,7 +1465,7 @@ fn test_basic_span() {
"code.lineno",
),
Int(
32,
37,
),
),
),
Expand Down