diff --git a/opentelemetry-appender-log/src/lib.rs b/opentelemetry-appender-log/src/lib.rs index 81ec10d129..878c45a7bc 100644 --- a/opentelemetry-appender-log/src/lib.rs +++ b/opentelemetry-appender-log/src/lib.rs @@ -769,7 +769,7 @@ mod tests { use super::OpenTelemetryLogBridge; use opentelemetry::{logs::AnyValue, StringValue}; - use opentelemetry_sdk::{logs::LoggerProvider, testing::logs::InMemoryLogExporter}; + use opentelemetry_sdk::{logs::InMemoryLogExporter, logs::LoggerProvider}; use log::Log; diff --git a/opentelemetry-appender-tracing/src/layer.rs b/opentelemetry-appender-tracing/src/layer.rs index 32a8a5b1f0..849dab60f5 100644 --- a/opentelemetry-appender-tracing/src/layer.rs +++ b/opentelemetry-appender-tracing/src/layer.rs @@ -213,9 +213,9 @@ mod tests { use opentelemetry::trace::TracerProvider as _; use opentelemetry::trace::{TraceContextExt, TraceFlags, Tracer}; use opentelemetry::{logs::AnyValue, Key}; + use opentelemetry_sdk::logs::InMemoryLogExporter; use opentelemetry_sdk::logs::{LogBatch, LogExporter}; use opentelemetry_sdk::logs::{LogRecord, LogResult, LoggerProvider}; - use opentelemetry_sdk::testing::logs::InMemoryLogExporter; use opentelemetry_sdk::trace::{Sampler, TracerProvider}; use tracing::{error, warn}; use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt; diff --git a/opentelemetry-sdk/CHANGELOG.md b/opentelemetry-sdk/CHANGELOG.md index 45a4ff63e8..52aad8230b 100644 --- a/opentelemetry-sdk/CHANGELOG.md +++ b/opentelemetry-sdk/CHANGELOG.md @@ -268,19 +268,26 @@ hardcoded limit of 2000 and no ability to change it. This feature will be re-introduced in a future date, along with the ability to change the cardinality limit. + - *Breaking* (Affects custom Exporter authors only) Moved `ExportError` trait from `opentelemetry::export::ExportError` to `opentelemetry_sdk::ExportError` -- *Breaking (Affects custom SpanExporter, SpanProcessor authors only)*: Rename namespaces +- *Breaking (Affects custom SpanExporter, SpanProcessor authors only)*: Rename namespaces for Span exporter structs/traits before: `opentelemetry_sdk::export::spans::{ExportResult, SpanData, SpanExporter};` now: - `opentelemetry_sdk::logs::{ExportResult, SpanData, SpanExporter};` + `opentelemetry_sdk::spans::{ExportResult, SpanData, SpanExporter};` -- *Breaking (Affects custom LogExporter, LogProcessor authors only)*: Rename namespaces +- *Breaking (Affects custom LogExporter, LogProcessor authors only)*: Rename namespaces for Log exporter structs/traits. before: `opentelemetry_sdk::export::logs::{ExportResult, LogBatch, LogExporter};` now: `opentelemetry_sdk::logs::{ExportResult, LogBatch, LogExporter};` +- *Breaking*: Rename namespaces for InMemoryExporters. (The module is still under "testing" feature flag) + before: + `opentelemetry_sdk::testing::logs::{InMemoryLogExporter, InMemoryLogExporterBuilder};` + now: + `opentelemetry_sdk::logs::{InMemoryLogExporter, InMemoryLogExporterBuilder};` + ## 0.27.1 Released 2024-Nov-27 diff --git a/opentelemetry-sdk/src/testing/logs/in_memory_exporter.rs b/opentelemetry-sdk/src/logs/in_memory_exporter.rs similarity index 94% rename from opentelemetry-sdk/src/testing/logs/in_memory_exporter.rs rename to opentelemetry-sdk/src/logs/in_memory_exporter.rs index a59b8e4c2d..0df3a0caeb 100644 --- a/opentelemetry-sdk/src/testing/logs/in_memory_exporter.rs +++ b/opentelemetry-sdk/src/logs/in_memory_exporter.rs @@ -15,7 +15,7 @@ use std::sync::{Arc, Mutex}; /// ```no_run ///# use opentelemetry_sdk::logs::{BatchLogProcessor, LoggerProvider}; ///# use opentelemetry_sdk::runtime; -///# use opentelemetry_sdk::testing::logs::InMemoryLogExporter; +///# use opentelemetry_sdk::logs::InMemoryLogExporter; /// ///# #[tokio::main] ///# async fn main() { @@ -72,7 +72,7 @@ pub struct LogDataWithResource { /// # Example /// /// ```no_run -///# use opentelemetry_sdk::testing::logs::{InMemoryLogExporter, InMemoryLogExporterBuilder}; +///# use opentelemetry_sdk::logs::{InMemoryLogExporter, InMemoryLogExporterBuilder}; ///# use opentelemetry_sdk::logs::{BatchLogProcessor, LoggerProvider}; ///# use opentelemetry_sdk::runtime; /// @@ -139,7 +139,7 @@ impl InMemoryLogExporter { /// # Example /// /// ``` - /// use opentelemetry_sdk::testing::logs::{InMemoryLogExporter, InMemoryLogExporterBuilder}; + /// use opentelemetry_sdk::logs::{InMemoryLogExporter, InMemoryLogExporterBuilder}; /// /// let exporter = InMemoryLogExporterBuilder::default().build(); /// let emitted_logs = exporter.get_emitted_logs().unwrap(); @@ -164,7 +164,7 @@ impl InMemoryLogExporter { /// # Example /// /// ``` - /// use opentelemetry_sdk::testing::logs::{InMemoryLogExporter, InMemoryLogExporterBuilder}; + /// use opentelemetry_sdk::logs::{InMemoryLogExporter, InMemoryLogExporterBuilder}; /// /// let exporter = InMemoryLogExporterBuilder::default().build(); /// exporter.reset(); diff --git a/opentelemetry-sdk/src/logs/log_emitter.rs b/opentelemetry-sdk/src/logs/log_emitter.rs index cb3c02a69d..94546f7c61 100644 --- a/opentelemetry-sdk/src/logs/log_emitter.rs +++ b/opentelemetry-sdk/src/logs/log_emitter.rs @@ -333,10 +333,10 @@ impl opentelemetry::logs::Logger for Logger { #[cfg(test)] mod tests { use crate::{ + logs::InMemoryLogExporter, resource::{ SERVICE_NAME, TELEMETRY_SDK_LANGUAGE, TELEMETRY_SDK_NAME, TELEMETRY_SDK_VERSION, }, - testing::logs::InMemoryLogExporter, trace::TracerProvider, Resource, }; diff --git a/opentelemetry-sdk/src/logs/log_processor.rs b/opentelemetry-sdk/src/logs/log_processor.rs index ff0275a8e8..68ba64bb7a 100644 --- a/opentelemetry-sdk/src/logs/log_processor.rs +++ b/opentelemetry-sdk/src/logs/log_processor.rs @@ -122,7 +122,7 @@ pub trait LogProcessor: Send + Sync + Debug { /// ```rust /// use opentelemetry_sdk::logs::{SimpleLogProcessor, LoggerProvider, LogExporter}; /// use opentelemetry::global; -/// use opentelemetry_sdk::testing::logs::InMemoryLogExporter; +/// use opentelemetry_sdk::logs::InMemoryLogExporter; /// /// let exporter = InMemoryLogExporter::default(); // Replace with an actual exporter /// let provider = LoggerProvider::builder() @@ -246,7 +246,7 @@ type LogsData = Box<(LogRecord, InstrumentationScope)>; /// use opentelemetry_sdk::logs::{BatchLogProcessor, BatchConfigBuilder, LoggerProvider}; /// use opentelemetry::global; /// use std::time::Duration; -/// use opentelemetry_sdk::testing::logs::InMemoryLogExporter; +/// use opentelemetry_sdk::logs::InMemoryLogExporter; /// /// let exporter = InMemoryLogExporter::default(); // Replace with an actual exporter /// let processor = BatchLogProcessor::builder(exporter) @@ -818,16 +818,15 @@ mod tests { }; use crate::logs::LogResult; use crate::logs::{LogBatch, LogExporter, LogRecord}; - use crate::testing::logs::InMemoryLogExporterBuilder; use crate::{ logs::{ log_processor::{ OTEL_BLRP_EXPORT_TIMEOUT_DEFAULT, OTEL_BLRP_MAX_EXPORT_BATCH_SIZE_DEFAULT, OTEL_BLRP_MAX_QUEUE_SIZE_DEFAULT, OTEL_BLRP_SCHEDULE_DELAY_DEFAULT, }, - BatchConfig, BatchConfigBuilder, LogProcessor, LoggerProvider, SimpleLogProcessor, + BatchConfig, BatchConfigBuilder, InMemoryLogExporter, InMemoryLogExporterBuilder, + LogProcessor, LoggerProvider, SimpleLogProcessor, }, - testing::logs::InMemoryLogExporter, Resource, }; use opentelemetry::logs::AnyValue; diff --git a/opentelemetry-sdk/src/logs/log_processor_with_async_runtime.rs b/opentelemetry-sdk/src/logs/log_processor_with_async_runtime.rs index ccd918be5d..781c7bb054 100644 --- a/opentelemetry-sdk/src/logs/log_processor_with_async_runtime.rs +++ b/opentelemetry-sdk/src/logs/log_processor_with_async_runtime.rs @@ -286,20 +286,20 @@ mod tests { OTEL_BLRP_SCHEDULE_DELAY, }; use crate::logs::log_processor_with_async_runtime::BatchLogProcessor; + use crate::logs::InMemoryLogExporterBuilder; use crate::logs::LogRecord; use crate::logs::LogResult; use crate::logs::{LogBatch, LogExporter}; use crate::runtime; - use crate::testing::logs::InMemoryLogExporterBuilder; use crate::{ logs::{ log_processor::{ OTEL_BLRP_EXPORT_TIMEOUT_DEFAULT, OTEL_BLRP_MAX_EXPORT_BATCH_SIZE_DEFAULT, OTEL_BLRP_MAX_QUEUE_SIZE_DEFAULT, OTEL_BLRP_SCHEDULE_DELAY_DEFAULT, }, - BatchConfig, BatchConfigBuilder, LogProcessor, LoggerProvider, SimpleLogProcessor, + BatchConfig, BatchConfigBuilder, InMemoryLogExporter, LogProcessor, LoggerProvider, + SimpleLogProcessor, }, - testing::logs::InMemoryLogExporter, Resource, }; use opentelemetry::logs::AnyValue; diff --git a/opentelemetry-sdk/src/logs/mod.rs b/opentelemetry-sdk/src/logs/mod.rs index 9fa8824001..d6127c9a29 100644 --- a/opentelemetry-sdk/src/logs/mod.rs +++ b/opentelemetry-sdk/src/logs/mod.rs @@ -5,6 +5,14 @@ mod log_emitter; mod log_processor; pub(crate) mod record; +/// In-Memory log exporter for testing purpose. +#[cfg(any(feature = "testing", test))] +#[cfg_attr(docsrs, doc(cfg(any(feature = "testing", test))))] +pub mod in_memory_exporter; +#[cfg(any(feature = "testing", test))] +#[cfg_attr(docsrs, doc(cfg(any(feature = "testing", test))))] +pub use in_memory_exporter::{InMemoryLogExporter, InMemoryLogExporterBuilder}; + pub use error::{LogError, LogResult}; pub use export::{ExportResult, LogBatch, LogExporter}; pub use log_emitter::{Builder, Logger, LoggerProvider}; @@ -21,7 +29,6 @@ pub mod log_processor_with_async_runtime; #[cfg(all(test, feature = "testing"))] mod tests { use super::*; - use crate::testing::logs::InMemoryLogExporter; use crate::Resource; use opentelemetry::logs::LogRecord; use opentelemetry::logs::{Logger, LoggerProvider as _, Severity}; diff --git a/opentelemetry-sdk/src/testing/logs/mod.rs b/opentelemetry-sdk/src/testing/logs/mod.rs deleted file mode 100644 index ed4d5d9560..0000000000 --- a/opentelemetry-sdk/src/testing/logs/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -//! In-Memory log exporter for testing purpose. - -/// The `in_memory_exporter` module provides in-memory log exporter. -/// For detailed usage and examples, see `in_memory_exporter`. -pub mod in_memory_exporter; -pub use in_memory_exporter::{InMemoryLogExporter, InMemoryLogExporterBuilder}; diff --git a/opentelemetry-sdk/src/testing/mod.rs b/opentelemetry-sdk/src/testing/mod.rs index 50c79f5d49..e8f7071a74 100644 --- a/opentelemetry-sdk/src/testing/mod.rs +++ b/opentelemetry-sdk/src/testing/mod.rs @@ -5,6 +5,3 @@ pub mod trace; #[cfg(all(feature = "testing", feature = "metrics"))] pub mod metrics; - -#[cfg(all(feature = "testing", feature = "logs"))] -pub mod logs;