Skip to content

Commit 91c685f

Browse files
lalitbcijothomas
andauthored
Small cleanup in Logs SDK. (#1850)
Co-authored-by: Cijo Thomas <[email protected]>
1 parent 300f8e5 commit 91c685f

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

opentelemetry-sdk/CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
- `SpanData` doesn't have the resource attributes. The `SpanExporter::export()` method needs to merge it
4242
with the earlier preserved resource before export.
4343

44-
- **Breaking** [1836](https://github.com/open-telemetry/opentelemetry-rust/pull/1836) `SpanProcessor::shutdown` now takes an immutable reference to self. Any reference can call shutdown on the processor. After the first call to `shutdown` the processor will not process any new spans.
44+
- **Breaking** [1836](https://github.com/open-telemetry/opentelemetry-rust/pull/1836) `SpanProcessor::shutdown` now takes an immutable reference to self. Any reference can call shutdown on the processor. After the first call to `shutdown` the processor will not process any new spans.
45+
46+
- **Breaking** [1850] (https://github.com/open-telemetry/opentelemetry-rust/pull/1850) `LoggerProvider::log_processors()` and `LoggerProvider::resource()` are not public methods anymore. They are only used within the `opentelemetry-sdk` crate.
4547

4648
## v0.23.0
4749

opentelemetry-sdk/src/logs/log_emitter.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,12 @@ impl LoggerProvider {
9090
Builder::default()
9191
}
9292

93-
/// Resource associated with this provider.
94-
pub fn resource(&self) -> &Resource {
95-
&self.inner.resource
93+
pub(crate) fn log_processors(&self) -> &[Box<dyn LogProcessor>] {
94+
&self.inner.processors
9695
}
9796

98-
/// Log processors associated with this provider.
99-
pub fn log_processors(&self) -> &[Box<dyn LogProcessor>] {
100-
&self.inner.processors
97+
pub(crate) fn resource(&self) -> &Resource {
98+
&self.inner.resource
10199
}
102100

103101
/// Force flush all remaining logs in log processors and return results.
@@ -196,17 +194,20 @@ impl Builder {
196194
/// Create a new provider from this configuration.
197195
pub fn build(self) -> LoggerProvider {
198196
let resource = self.resource.unwrap_or_default();
199-
// invoke set_resource on all the processors
200-
for processor in &self.processors {
201-
processor.set_resource(&resource);
202-
}
203-
LoggerProvider {
197+
198+
let logger_provider = LoggerProvider {
204199
inner: Arc::new(LoggerProviderInner {
205200
processors: self.processors,
206201
resource,
207202
}),
208203
is_shutdown: Arc::new(AtomicBool::new(false)),
204+
};
205+
206+
// invoke set_resource on all the processors
207+
for processor in logger_provider.log_processors() {
208+
processor.set_resource(logger_provider.resource());
209209
}
210+
logger_provider
210211
}
211212
}
212213

0 commit comments

Comments
 (0)