Skip to content

Commit 78a4444

Browse files
Remove duplicate InstrumentationScope/Scope re-exports in SDK
1 parent 1b41f6c commit 78a4444

File tree

24 files changed

+96
-126
lines changed

24 files changed

+96
-126
lines changed

opentelemetry-proto/src/transform/common.rs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,8 @@ pub mod tonic {
4242
#[cfg(any(feature = "trace", feature = "logs"))]
4343
use opentelemetry_sdk::Resource;
4444

45-
impl
46-
From<(
47-
opentelemetry_sdk::InstrumentationScope,
48-
Option<Cow<'static, str>>,
49-
)> for InstrumentationScope
50-
{
51-
fn from(
52-
data: (
53-
opentelemetry_sdk::InstrumentationScope,
54-
Option<Cow<'static, str>>,
55-
),
56-
) -> Self {
45+
impl From<(opentelemetry_sdk::Scope, Option<Cow<'static, str>>)> for InstrumentationScope {
46+
fn from(data: (opentelemetry_sdk::Scope, Option<Cow<'static, str>>)) -> Self {
5747
let (library, target) = data;
5848
if let Some(t) = target {
5949
InstrumentationScope {
@@ -73,18 +63,8 @@ pub mod tonic {
7363
}
7464
}
7565

76-
impl
77-
From<(
78-
&opentelemetry_sdk::InstrumentationScope,
79-
Option<Cow<'static, str>>,
80-
)> for InstrumentationScope
81-
{
82-
fn from(
83-
data: (
84-
&opentelemetry_sdk::InstrumentationScope,
85-
Option<Cow<'static, str>>,
86-
),
87-
) -> Self {
66+
impl From<(&opentelemetry_sdk::Scope, Option<Cow<'static, str>>)> for InstrumentationScope {
67+
fn from(data: (&opentelemetry_sdk::Scope, Option<Cow<'static, str>>)) -> Self {
8868
let (library, target) = data;
8969
if let Some(t) = target {
9070
InstrumentationScope {

opentelemetry-proto/src/transform/trace.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ pub mod tonic {
158158
// Group spans by their instrumentation library
159159
let scope_map = spans.iter().fold(
160160
HashMap::new(),
161-
|mut scope_map: HashMap<&opentelemetry_sdk::InstrumentationScope, Vec<&SpanData>>,
162-
span| {
161+
|mut scope_map: HashMap<&opentelemetry_sdk::Scope, Vec<&SpanData>>, span| {
163162
let instrumentation = &span.instrumentation_scope;
164163
scope_map.entry(instrumentation).or_default().push(span);
165164
scope_map
@@ -202,7 +201,7 @@ mod tests {
202201
use opentelemetry_sdk::export::trace::SpanData;
203202
use opentelemetry_sdk::resource::Resource;
204203
use opentelemetry_sdk::trace::{SpanEvents, SpanLinks};
205-
use opentelemetry_sdk::InstrumentationScope;
204+
use opentelemetry_sdk::Scope;
206205
use std::borrow::Cow;
207206
use std::time::{Duration, SystemTime};
208207

@@ -227,7 +226,7 @@ mod tests {
227226
events: SpanEvents::default(),
228227
links: SpanLinks::default(),
229228
status: Status::Unset,
230-
instrumentation_scope: InstrumentationScope::builder(instrumentation_name).build(),
229+
instrumentation_scope: Scope::builder(instrumentation_name).build(),
231230
}
232231
}
233232

opentelemetry-sdk/benches/log.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ use opentelemetry::logs::{
2525
};
2626
use opentelemetry::trace::Tracer;
2727
use opentelemetry::trace::TracerProvider as _;
28-
use opentelemetry::{InstrumentationScope, Key};
28+
use opentelemetry::Key;
2929
use opentelemetry_sdk::logs::{LogProcessor, LogRecord, Logger, LoggerProvider};
3030
use opentelemetry_sdk::trace;
3131
use opentelemetry_sdk::trace::{Sampler, TracerProvider};
32+
use opentelemetry_sdk::Scope;
3233

3334
#[derive(Debug)]
3435
struct NoopProcessor;
3536

3637
impl LogProcessor for NoopProcessor {
37-
fn emit(&self, _data: &mut LogRecord, _scope: &InstrumentationScope) {}
38+
fn emit(&self, _data: &mut LogRecord, _scope: &Scope) {}
3839

3940
fn force_flush(&self) -> LogResult<()> {
4041
Ok(())

opentelemetry-sdk/benches/log_exporter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ use criterion::{criterion_group, criterion_main, Criterion};
1818

1919
use opentelemetry::logs::{LogRecord as _, LogResult, Logger as _, LoggerProvider as _, Severity};
2020

21-
use opentelemetry::InstrumentationScope;
2221
use opentelemetry_sdk::export::logs::LogBatch;
2322
use opentelemetry_sdk::logs::LogProcessor;
2423
use opentelemetry_sdk::logs::LogRecord;
2524
use opentelemetry_sdk::logs::LoggerProvider;
25+
use opentelemetry_sdk::Scope;
2626
use pprof::criterion::{Output, PProfProfiler};
2727
use std::fmt::Debug;
2828

@@ -65,7 +65,7 @@ impl ExportingProcessorWithFuture {
6565
}
6666

6767
impl LogProcessor for ExportingProcessorWithFuture {
68-
fn emit(&self, record: &mut LogRecord, scope: &InstrumentationScope) {
68+
fn emit(&self, record: &mut LogRecord, scope: &Scope) {
6969
let mut exporter = self.exporter.lock().expect("lock error");
7070
let logs = [(record as &LogRecord, scope)];
7171
futures_executor::block_on(exporter.export(LogBatch::new(&logs)));
@@ -94,7 +94,7 @@ impl ExportingProcessorWithoutFuture {
9494
}
9595

9696
impl LogProcessor for ExportingProcessorWithoutFuture {
97-
fn emit(&self, record: &mut LogRecord, scope: &InstrumentationScope) {
97+
fn emit(&self, record: &mut LogRecord, scope: &Scope) {
9898
let logs = [(record as &LogRecord, scope)];
9999
self.exporter
100100
.lock()

opentelemetry-sdk/benches/log_processor.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use std::{
1919

2020
use criterion::{criterion_group, criterion_main, Criterion};
2121
use opentelemetry::logs::{LogRecord as _, LogResult, Logger as _, LoggerProvider as _, Severity};
22-
use opentelemetry::InstrumentationScope;
2322
use opentelemetry_sdk::logs::{LogProcessor, LogRecord, Logger, LoggerProvider};
23+
use opentelemetry_sdk::Scope;
2424

2525
// Run this benchmark with:
2626
// cargo bench --bench log_processor
@@ -43,7 +43,7 @@ fn create_log_record(logger: &Logger) -> LogRecord {
4343
struct NoopProcessor;
4444

4545
impl LogProcessor for NoopProcessor {
46-
fn emit(&self, _data: &mut LogRecord, _scope: &InstrumentationScope) {}
46+
fn emit(&self, _data: &mut LogRecord, _scope: &Scope) {}
4747

4848
fn force_flush(&self) -> LogResult<()> {
4949
Ok(())
@@ -58,7 +58,7 @@ impl LogProcessor for NoopProcessor {
5858
struct CloningProcessor;
5959

6060
impl LogProcessor for CloningProcessor {
61-
fn emit(&self, data: &mut LogRecord, _scope: &InstrumentationScope) {
61+
fn emit(&self, data: &mut LogRecord, _scope: &Scope) {
6262
let _data_cloned = data.clone();
6363
}
6464

@@ -73,8 +73,8 @@ impl LogProcessor for CloningProcessor {
7373

7474
#[derive(Debug)]
7575
struct SendToChannelProcessor {
76-
sender: std::sync::mpsc::Sender<(LogRecord, InstrumentationScope)>,
77-
receiver: Arc<Mutex<std::sync::mpsc::Receiver<(LogRecord, InstrumentationScope)>>>,
76+
sender: std::sync::mpsc::Sender<(LogRecord, Scope)>,
77+
receiver: Arc<Mutex<std::sync::mpsc::Receiver<(LogRecord, Scope)>>>,
7878
}
7979

8080
impl SendToChannelProcessor {
@@ -101,7 +101,7 @@ impl SendToChannelProcessor {
101101
}
102102

103103
impl LogProcessor for SendToChannelProcessor {
104-
fn emit(&self, record: &mut LogRecord, scope: &InstrumentationScope) {
104+
fn emit(&self, record: &mut LogRecord, scope: &Scope) {
105105
let res = self.sender.send((record.clone(), scope.clone()));
106106
if res.is_err() {
107107
println!("Error sending log data to channel {0}", res.err().unwrap());

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
//! Log exporters
22
use crate::logs::LogRecord;
33
use crate::Resource;
4+
use crate::Scope;
45
use async_trait::async_trait;
56
#[cfg(feature = "logs_level_enabled")]
67
use opentelemetry::logs::Severity;
7-
use opentelemetry::{
8-
logs::{LogError, LogResult},
9-
InstrumentationScope,
10-
};
8+
use opentelemetry::logs::{LogError, LogResult};
119
use std::fmt::Debug;
1210

1311
/// A batch of log records to be exported by a `LogExporter`.
@@ -22,8 +20,8 @@ use std::fmt::Debug;
2220
#[derive(Debug)]
2321
pub struct LogBatch<'a> {
2422
/// The data field contains a slice of tuples, where each tuple consists of a reference to
25-
/// a `LogRecord` and a reference to an `InstrumentationScope`.
26-
data: &'a [(&'a LogRecord, &'a InstrumentationScope)],
23+
/// a `LogRecord` and a reference to an `Scope`.
24+
data: &'a [(&'a LogRecord, &'a Scope)],
2725
}
2826

2927
impl<'a> LogBatch<'a> {
@@ -32,7 +30,7 @@ impl<'a> LogBatch<'a> {
3230
/// # Arguments
3331
///
3432
/// * `data` - A slice of tuples, where each tuple consists of a reference to a `LogRecord`
35-
/// and a reference to an `InstrumentationScope`. These tuples represent the log records
33+
/// and a reference to an `Scope`. These tuples represent the log records
3634
/// and their associated instrumentation libraries to be exported.
3735
///
3836
/// # Returns
@@ -42,7 +40,7 @@ impl<'a> LogBatch<'a> {
4240
/// Note - this is not a public function, and should not be used directly. This would be
4341
/// made private in the future.
4442
45-
pub fn new(data: &'a [(&'a LogRecord, &'a InstrumentationScope)]) -> LogBatch<'a> {
43+
pub fn new(data: &'a [(&'a LogRecord, &'a Scope)]) -> LogBatch<'a> {
4644
LogBatch { data }
4745
}
4846
}
@@ -51,13 +49,13 @@ impl LogBatch<'_> {
5149
/// Returns an iterator over the log records and instrumentation libraries in the batch.
5250
///
5351
/// Each item yielded by the iterator is a tuple containing references to a `LogRecord`
54-
/// and an `InstrumentationScope`.
52+
/// and an `Scope`.
5553
///
5654
/// # Returns
5755
///
58-
/// An iterator that yields references to the `LogRecord` and `InstrumentationScope` in the batch.
56+
/// An iterator that yields references to the `LogRecord` and `Scope` in the batch.
5957
///
60-
pub fn iter(&self) -> impl Iterator<Item = (&LogRecord, &InstrumentationScope)> {
58+
pub fn iter(&self) -> impl Iterator<Item = (&LogRecord, &Scope)> {
6159
self.data
6260
.iter()
6361
.map(|(record, library)| (*record, *library))

opentelemetry-sdk/src/export/trace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,5 @@ pub struct SpanData {
9696
/// Span status
9797
pub status: Status,
9898
/// Instrumentation library that produced this span
99-
pub instrumentation_scope: crate::InstrumentationScope,
99+
pub instrumentation_scope: crate::Scope,
100100
}

opentelemetry-sdk/src/instrumentation.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

opentelemetry-sdk/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122

123123
pub mod export;
124124
pub(crate) mod growable_array;
125-
mod instrumentation;
125+
126126
#[cfg(feature = "logs")]
127127
#[cfg_attr(docsrs, doc(cfg(feature = "logs")))]
128128
pub mod logs;
@@ -146,6 +146,7 @@ pub mod trace;
146146
#[doc(hidden)]
147147
pub mod util;
148148

149-
pub use instrumentation::{InstrumentationScope, Scope};
149+
#[doc(inline)]
150+
pub use opentelemetry::InstrumentationScope as Scope;
150151
#[doc(inline)]
151152
pub use resource::Resource;

opentelemetry-sdk/src/logs/log_emitter.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use super::{BatchLogProcessor, LogProcessor, LogRecord, SimpleLogProcessor, TraceContext};
2-
use crate::{export::logs::LogExporter, runtime::RuntimeChannel, Resource};
2+
use crate::{export::logs::LogExporter, runtime::RuntimeChannel, Resource, Scope};
33
use opentelemetry::{
44
logs::{LogError, LogResult},
55
otel_debug,
66
trace::TraceContextExt,
7-
Context, InstrumentationScope,
7+
Context,
88
};
99

1010
#[cfg(feature = "logs_level_enabled")]
@@ -48,7 +48,7 @@ pub struct LoggerProvider {
4848
impl opentelemetry::logs::LoggerProvider for LoggerProvider {
4949
type Logger = Logger;
5050

51-
fn logger_with_scope(&self, scope: InstrumentationScope) -> Self::Logger {
51+
fn logger_with_scope(&self, scope: Scope) -> Self::Logger {
5252
// If the provider is shutdown, new logger will refer a no-op logger provider.
5353
if self.inner.is_shutdown.load(Ordering::Relaxed) {
5454
return Logger::new(scope, NOOP_LOGGER_PROVIDER.clone());
@@ -217,12 +217,12 @@ impl Builder {
217217
///
218218
/// [`LogRecord`]: opentelemetry::logs::LogRecord
219219
pub struct Logger {
220-
scope: InstrumentationScope,
220+
scope: Scope,
221221
provider: LoggerProvider,
222222
}
223223

224224
impl Logger {
225-
pub(crate) fn new(scope: InstrumentationScope, provider: LoggerProvider) -> Self {
225+
pub(crate) fn new(scope: Scope, provider: LoggerProvider) -> Self {
226226
Logger { scope, provider }
227227
}
228228

@@ -232,7 +232,7 @@ impl Logger {
232232
}
233233

234234
/// Instrumentation library information of this logger.
235-
pub fn instrumentation_scope(&self) -> &InstrumentationScope {
235+
pub fn instrumentation_scope(&self) -> &Scope {
236236
&self.scope
237237
}
238238
}
@@ -327,7 +327,7 @@ mod tests {
327327
}
328328

329329
impl LogProcessor for ShutdownTestLogProcessor {
330-
fn emit(&self, _data: &mut LogRecord, _scope: &InstrumentationScope) {
330+
fn emit(&self, _data: &mut LogRecord, _scope: &Scope) {
331331
self.is_shutdown
332332
.lock()
333333
.map(|is_shutdown| {
@@ -706,7 +706,7 @@ mod tests {
706706
}
707707

708708
impl LogProcessor for LazyLogProcessor {
709-
fn emit(&self, _data: &mut LogRecord, _scope: &InstrumentationScope) {
709+
fn emit(&self, _data: &mut LogRecord, _scope: &Scope) {
710710
// nothing to do.
711711
}
712712

@@ -737,7 +737,7 @@ mod tests {
737737
}
738738

739739
impl LogProcessor for CountingShutdownProcessor {
740-
fn emit(&self, _data: &mut LogRecord, _scope: &InstrumentationScope) {
740+
fn emit(&self, _data: &mut LogRecord, _scope: &Scope) {
741741
// nothing to do
742742
}
743743

0 commit comments

Comments
 (0)