Skip to content

Commit 4d26d7a

Browse files
authored
Add Sync bound on the LogExporter and SpanExporter traits (#1240)
1 parent 6412dcd commit 4d26d7a

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

opentelemetry-sdk/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
is now the API crate. [#1226](https://github.com/open-telemetry/opentelemetry-rust/pull/1226)
1414
- Add in memory span exporter [#1216](https://github.com/open-telemetry/opentelemetry-rust/pull/1216)
1515
- Add in memory log exporter [#1231](https://github.com/open-telemetry/opentelemetry-rust/pull/1231)
16+
- Add `Sync` bound to the `SpanExporter` and `LogExporter` traits [#1240](https://github.com/open-telemetry/opentelemetry-rust/pull/1240)
1617

1718
### Removed
1819

opentelemetry-sdk/src/export/logs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{borrow::Cow, fmt::Debug};
1111

1212
/// `LogExporter` defines the interface that log exporters should implement.
1313
#[async_trait]
14-
pub trait LogExporter: Send + Debug {
14+
pub trait LogExporter: Send + Sync + Debug {
1515
/// Exports a batch of [`LogData`].
1616
async fn export(&mut self, batch: Vec<LogData>) -> LogResult<()>;
1717
/// Shuts down the exporter.

opentelemetry-sdk/src/export/trace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub type ExportResult = Result<(), TraceError>;
1616
/// The goal of the interface is to minimize burden of implementation for
1717
/// protocol-dependent telemetry exporters. The protocol exporter is expected to
1818
/// be primarily a simple telemetry data encoder and transmitter.
19-
pub trait SpanExporter: Send + Debug {
19+
pub trait SpanExporter: Send + Sync + Debug {
2020
/// Exports a batch of readable spans. Protocol exporters that will
2121
/// implement this function are typically expected to serialize and transmit
2222
/// the data to the destination.

opentelemetry-sdk/src/testing/trace/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ use crate::{
1111
InstrumentationLibrary,
1212
};
1313
use async_trait::async_trait;
14+
use crossbeam_channel::{unbounded, Receiver, SendError, Sender};
1415
use futures_util::future::BoxFuture;
1516
pub use opentelemetry::testing::trace::TestSpan;
1617
use opentelemetry::trace::{
1718
SpanContext, SpanId, SpanKind, Status, TraceFlags, TraceId, TraceState,
1819
};
1920
use std::fmt::{Display, Formatter};
20-
use std::sync::mpsc::{channel, Receiver, Sender};
2121

2222
pub fn new_test_export_span_data() -> SpanData {
2323
let config = Config::default();
@@ -70,8 +70,8 @@ impl SpanExporter for TestSpanExporter {
7070
}
7171

7272
pub fn new_test_exporter() -> (TestSpanExporter, Receiver<SpanData>, Receiver<()>) {
73-
let (tx_export, rx_export) = channel();
74-
let (tx_shutdown, rx_shutdown) = channel();
73+
let (tx_export, rx_export) = unbounded();
74+
let (tx_shutdown, rx_shutdown) = unbounded();
7575
let exporter = TestSpanExporter {
7676
tx_export,
7777
tx_shutdown,
@@ -142,8 +142,8 @@ impl<T> From<tokio::sync::mpsc::error::SendError<T>> for TestExportError {
142142
}
143143
}
144144

145-
impl<T> From<std::sync::mpsc::SendError<T>> for TestExportError {
146-
fn from(err: std::sync::mpsc::SendError<T>) -> Self {
145+
impl<T> From<crossbeam_channel::SendError<T>> for TestExportError {
146+
fn from(err: SendError<T>) -> Self {
147147
TestExportError(err.to_string())
148148
}
149149
}

0 commit comments

Comments
 (0)