Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small cleanup in Logs SDK. #1850

Merged
merged 3 commits into from
May 31, 2024
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
4 changes: 3 additions & 1 deletion opentelemetry-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
- `SpanData` doesn't have the resource attributes. The `SpanExporter::export()` method needs to merge it
with the earlier preserved resource before export.

- **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.
- **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.

- **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.

## v0.23.0

Expand Down
23 changes: 12 additions & 11 deletions opentelemetry-sdk/src/logs/log_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,12 @@ impl LoggerProvider {
Builder::default()
}

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

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

/// Force flush all remaining logs in log processors and return results.
Expand Down Expand Up @@ -196,17 +194,20 @@ impl Builder {
/// Create a new provider from this configuration.
pub fn build(self) -> LoggerProvider {
let resource = self.resource.unwrap_or_default();
// invoke set_resource on all the processors
for processor in &self.processors {
processor.set_resource(&resource);
}
LoggerProvider {

let logger_provider = LoggerProvider {
inner: Arc::new(LoggerProviderInner {
processors: self.processors,
resource,
}),
is_shutdown: Arc::new(AtomicBool::new(false)),
};

// invoke set_resource on all the processors
for processor in logger_provider.log_processors() {
processor.set_resource(logger_provider.resource());
}
logger_provider
}
}

Expand Down
Loading