diff --git a/opentelemetry-appender-tracing/benches/logs.rs b/opentelemetry-appender-tracing/benches/logs.rs index e5fb98273c..6c09f5c966 100644 --- a/opentelemetry-appender-tracing/benches/logs.rs +++ b/opentelemetry-appender-tracing/benches/logs.rs @@ -16,8 +16,8 @@ use criterion::{criterion_group, criterion_main, Criterion}; use opentelemetry::InstrumentationScope; use opentelemetry_appender_tracing::layer as tracing_layer; -use opentelemetry_sdk::export::logs::{LogBatch, LogExporter}; use opentelemetry_sdk::logs::LogResult; +use opentelemetry_sdk::logs::{LogBatch, LogExporter}; use opentelemetry_sdk::logs::{LogProcessor, LogRecord, LoggerProvider}; use opentelemetry_sdk::Resource; use pprof::criterion::{Output, PProfProfiler}; diff --git a/opentelemetry-appender-tracing/src/layer.rs b/opentelemetry-appender-tracing/src/layer.rs index af752c5f8e..32a8a5b1f0 100644 --- a/opentelemetry-appender-tracing/src/layer.rs +++ b/opentelemetry-appender-tracing/src/layer.rs @@ -213,7 +213,7 @@ mod tests { use opentelemetry::trace::TracerProvider as _; use opentelemetry::trace::{TraceContextExt, TraceFlags, Tracer}; use opentelemetry::{logs::AnyValue, Key}; - use opentelemetry_sdk::export::logs::{LogBatch, LogExporter}; + 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}; diff --git a/opentelemetry-otlp/src/exporter/http/logs.rs b/opentelemetry-otlp/src/exporter/http/logs.rs index 9d00602eed..8b828730cd 100644 --- a/opentelemetry-otlp/src/exporter/http/logs.rs +++ b/opentelemetry-otlp/src/exporter/http/logs.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use http::{header::CONTENT_TYPE, Method}; use opentelemetry::otel_debug; -use opentelemetry_sdk::export::logs::{LogBatch, LogExporter}; +use opentelemetry_sdk::logs::{LogBatch, LogExporter}; use opentelemetry_sdk::logs::{LogError, LogResult}; use super::OtlpHttpClient; diff --git a/opentelemetry-otlp/src/exporter/http/mod.rs b/opentelemetry-otlp/src/exporter/http/mod.rs index 4d1af8c880..38dc978a29 100644 --- a/opentelemetry-otlp/src/exporter/http/mod.rs +++ b/opentelemetry-otlp/src/exporter/http/mod.rs @@ -13,10 +13,10 @@ use opentelemetry_proto::transform::common::tonic::ResourceAttributesWithSchema; use opentelemetry_proto::transform::logs::tonic::group_logs_by_resource_and_scope; #[cfg(feature = "trace")] use opentelemetry_proto::transform::trace::tonic::group_spans_by_resource_and_scope; -#[cfg(feature = "logs")] -use opentelemetry_sdk::export::logs::LogBatch; #[cfg(feature = "trace")] use opentelemetry_sdk::export::trace::SpanData; +#[cfg(feature = "logs")] +use opentelemetry_sdk::logs::LogBatch; use prost::Message; use std::collections::HashMap; use std::env; @@ -27,6 +27,9 @@ use std::time::Duration; #[cfg(feature = "metrics")] mod metrics; +#[cfg(feature = "metrics")] +use opentelemetry_sdk::metrics::data::ResourceMetrics; + #[cfg(feature = "logs")] pub(crate) mod logs; @@ -336,7 +339,7 @@ impl OtlpHttpClient { #[cfg(feature = "metrics")] fn build_metrics_export_body( &self, - metrics: &mut opentelemetry_sdk::metrics::data::ResourceMetrics, + metrics: &mut ResourceMetrics, ) -> opentelemetry_sdk::metrics::MetricResult<(Vec, &'static str)> { use opentelemetry_proto::tonic::collector::metrics::v1::ExportMetricsServiceRequest; diff --git a/opentelemetry-otlp/src/exporter/tonic/logs.rs b/opentelemetry-otlp/src/exporter/tonic/logs.rs index 053331b428..a4d276fd8f 100644 --- a/opentelemetry-otlp/src/exporter/tonic/logs.rs +++ b/opentelemetry-otlp/src/exporter/tonic/logs.rs @@ -3,7 +3,7 @@ use opentelemetry::otel_debug; use opentelemetry_proto::tonic::collector::logs::v1::{ logs_service_client::LogsServiceClient, ExportLogsServiceRequest, }; -use opentelemetry_sdk::export::logs::{LogBatch, LogExporter}; +use opentelemetry_sdk::logs::{LogBatch, LogExporter}; use opentelemetry_sdk::logs::{LogError, LogResult}; use tonic::{codegen::CompressionEncoding, service::Interceptor, transport::Channel, Request}; diff --git a/opentelemetry-otlp/src/logs.rs b/opentelemetry-otlp/src/logs.rs index aa4ea8fa07..3b17c30feb 100644 --- a/opentelemetry-otlp/src/logs.rs +++ b/opentelemetry-otlp/src/logs.rs @@ -8,7 +8,7 @@ use std::fmt::Debug; use opentelemetry_sdk::logs::LogResult; -use opentelemetry_sdk::export::logs::LogBatch; +use opentelemetry_sdk::logs::LogBatch; use crate::{HasExportConfig, NoExporterBuilderSet}; @@ -140,7 +140,7 @@ impl LogExporter { } } -impl opentelemetry_sdk::export::logs::LogExporter for LogExporter { +impl opentelemetry_sdk::logs::LogExporter for LogExporter { #[allow(clippy::manual_async_fn)] fn export( &self, diff --git a/opentelemetry-proto/src/transform/logs.rs b/opentelemetry-proto/src/transform/logs.rs index b6f28490d7..37be35709b 100644 --- a/opentelemetry-proto/src/transform/logs.rs +++ b/opentelemetry-proto/src/transform/logs.rs @@ -12,7 +12,7 @@ pub mod tonic { transform::common::{to_nanos, tonic::ResourceAttributesWithSchema}, }; use opentelemetry::logs::{AnyValue as LogsAnyValue, Severity}; - use opentelemetry_sdk::export::logs::LogBatch; + use opentelemetry_sdk::logs::LogBatch; use std::borrow::Cow; use std::collections::HashMap; @@ -222,7 +222,7 @@ mod tests { use crate::transform::common::tonic::ResourceAttributesWithSchema; use opentelemetry::logs::LogRecord as _; use opentelemetry::InstrumentationScope; - use opentelemetry_sdk::{export::logs::LogBatch, logs::LogRecord, Resource}; + use opentelemetry_sdk::{logs::LogBatch, logs::LogRecord, Resource}; use std::time::SystemTime; fn create_test_log_data( diff --git a/opentelemetry-proto/src/transform/metrics.rs b/opentelemetry-proto/src/transform/metrics.rs index cb135ebf83..680da03b3f 100644 --- a/opentelemetry-proto/src/transform/metrics.rs +++ b/opentelemetry-proto/src/transform/metrics.rs @@ -10,8 +10,8 @@ pub mod tonic { use opentelemetry::{otel_debug, Key, Value}; use opentelemetry_sdk::metrics::data::{ - self, Exemplar as SdkExemplar, ExponentialHistogram as SdkExponentialHistogram, - Gauge as SdkGauge, Histogram as SdkHistogram, Metric as SdkMetric, + Exemplar as SdkExemplar, ExponentialHistogram as SdkExponentialHistogram, + Gauge as SdkGauge, Histogram as SdkHistogram, Metric as SdkMetric, ResourceMetrics, ScopeMetrics as SdkScopeMetrics, Sum as SdkSum, }; use opentelemetry_sdk::metrics::Temporality; @@ -110,8 +110,8 @@ pub mod tonic { } } - impl From<&data::ResourceMetrics> for ExportMetricsServiceRequest { - fn from(rm: &data::ResourceMetrics) -> Self { + impl From<&ResourceMetrics> for ExportMetricsServiceRequest { + fn from(rm: &ResourceMetrics) -> Self { ExportMetricsServiceRequest { resource_metrics: vec![TonicResourceMetrics { resource: Some((&rm.resource).into()), diff --git a/opentelemetry-sdk/CHANGELOG.md b/opentelemetry-sdk/CHANGELOG.md index b053853a11..dff61dddaa 100644 --- a/opentelemetry-sdk/CHANGELOG.md +++ b/opentelemetry-sdk/CHANGELOG.md @@ -17,6 +17,7 @@ - *Feature*: Add `ResourceBuilder` for an easy way to create new `Resource`s - *Breaking*: Remove `Resource::{new,empty,from_detectors,new_with_defaults,from_schema_url,merge,default}` from public api. To create Resources you should only use `Resource::builder()` or `Resource::builder_empty()`. See [#2322](https://github.com/open-telemetry/opentelemetry-rust/pull/2322) for a migration guide. Example Usage: + ```rust // old Resource::default().with_attributes([ @@ -30,6 +31,7 @@ .with_attribute(KeyValue::new("key", "value")) .build(); ``` + - *Breaking* The LogExporter::export() method no longer requires a mutable reference to self.: Before: async fn export(&mut self, _batch: LogBatch<'_>) -> LogResult<()> @@ -61,15 +63,18 @@ 1. *Default Implementation, requires no async runtime* (**Recommended**) The new default implementation does not require a runtime argument. Replace the builder method accordingly: - - *Before:* - ```rust - let reader = opentelemetry_sdk::metrics::PeriodicReader::builder(exporter, runtime::Tokio).build(); - ``` - - *After:* - ```rust - let reader = opentelemetry_sdk::metrics::PeriodicReader::builder(exporter).build(); + *Before:* + + ```rust + let reader = opentelemetry_sdk::metrics::PeriodicReader::builder(exporter, runtime::Tokio).build(); ``` + *After:* + + ```rust + let reader = opentelemetry_sdk::metrics::PeriodicReader::builder(exporter).build(); + ``` + The new PeriodicReader can be used with OTLP Exporter, and supports following exporter features: - `grpc-tonic`: This requires `MeterProvider` to be created within a tokio @@ -250,11 +255,11 @@ metadata, a feature introduced in version 0.1.40. [#2418](https://github.com/ope equal signs (`"="`). [#2120](https://github.com/open-telemetry/opentelemetry-rust/pull/2120) - **Breaking** Introduced `experimental_async_runtime` feature for runtime-specific traits. - - Runtime-specific features (`rt-tokio`, `rt-tokio-current-thread`, and `rt-async-std`) + - Runtime-specific features (`rt-tokio`, `rt-tokio-current-thread`, and `rt-async-std`) now depend on the `experimental_async_runtime` feature. - - For most users, no action is required. Enabling runtime features such as `rt-tokio`, `rt-tokio-current-thread`, + - For most users, no action is required. Enabling runtime features such as `rt-tokio`, `rt-tokio-current-thread`, or `rt-async-std` will automatically enable the `experimental_async_runtime` feature. - - If you're implementing a custom runtime, you must explicitly enable the experimental_async_runtime` feature in your + - If you're implementing a custom runtime, you must explicitly enable the experimental_async_runtime` feature in your Cargo.toml and implement the required `Runtime` traits. - Removed Metrics Cardinality Limit feature. This was originally introduced in @@ -263,6 +268,12 @@ 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 LogExporter, LogProcessor authors only)*: Rename namespaces + before: + `opentelemetry_sdk::export::logs::{ExportResult, LogBatch, LogExporter};` + now: + `opentelemetry_sdk::logs::{ExportResult, LogBatch, LogExporter};` + ## 0.27.1 Released 2024-Nov-27 @@ -271,6 +282,7 @@ Released 2024-Nov-27 - `trace::Config` methods are moving onto `TracerProvider` Builder to be consistent with other signals. See https://github.com/open-telemetry/opentelemetry-rust/pull/2303 for migration guide. `trace::Config` is scheduled to be removed from public API in `v0.28.0`. example: + ```rust // old let tracer_provider: TracerProvider = TracerProvider::builder() @@ -282,6 +294,7 @@ Released 2024-Nov-27 .with_resource(Resource::empty()) .build(); ``` + - `logs::LogData` struct is deprecated, and scheduled to be removed from public API in `v0.28.0`. - Bug fix: Empty Meter names are retained as-is instead of replacing with "rust.opentelemetry.io/sdk/meter" diff --git a/opentelemetry-sdk/benches/log_exporter.rs b/opentelemetry-sdk/benches/log_exporter.rs index c2ecb78ce9..523725fc7e 100644 --- a/opentelemetry-sdk/benches/log_exporter.rs +++ b/opentelemetry-sdk/benches/log_exporter.rs @@ -20,7 +20,7 @@ use opentelemetry::logs::{LogRecord as _, Logger as _, LoggerProvider as _, Seve use opentelemetry_sdk::logs::LogResult; use opentelemetry::InstrumentationScope; -use opentelemetry_sdk::export::logs::LogBatch; +use opentelemetry_sdk::logs::LogBatch; use opentelemetry_sdk::logs::LogProcessor; use opentelemetry_sdk::logs::LogRecord; use opentelemetry_sdk::logs::LoggerProvider; diff --git a/opentelemetry-sdk/src/export/mod.rs b/opentelemetry-sdk/src/export/mod.rs index 21dc2b570c..92f111c4e4 100644 --- a/opentelemetry-sdk/src/export/mod.rs +++ b/opentelemetry-sdk/src/export/mod.rs @@ -1,9 +1,5 @@ //! Telemetry Export -#[cfg(feature = "logs")] -#[cfg_attr(docsrs, doc(cfg(feature = "logs")))] -pub mod logs; - #[cfg(feature = "trace")] #[cfg_attr(docsrs, doc(cfg(feature = "trace")))] pub mod trace; diff --git a/opentelemetry-sdk/src/export/logs/mod.rs b/opentelemetry-sdk/src/logs/export.rs similarity index 100% rename from opentelemetry-sdk/src/export/logs/mod.rs rename to opentelemetry-sdk/src/logs/export.rs diff --git a/opentelemetry-sdk/src/logs/log_emitter.rs b/opentelemetry-sdk/src/logs/log_emitter.rs index 497cbb6db1..cb3c02a69d 100644 --- a/opentelemetry-sdk/src/logs/log_emitter.rs +++ b/opentelemetry-sdk/src/logs/log_emitter.rs @@ -1,6 +1,6 @@ use super::{BatchLogProcessor, LogProcessor, LogRecord, SimpleLogProcessor, TraceContext}; -use crate::{export::logs::LogExporter, Resource}; -use crate::{logs::LogError, logs::LogResult}; +use crate::logs::{LogError, LogExporter, LogResult}; +use crate::Resource; use opentelemetry::{otel_debug, otel_info, trace::TraceContextExt, Context, InstrumentationScope}; #[cfg(feature = "spec_unstable_logs_enabled")] diff --git a/opentelemetry-sdk/src/logs/log_processor.rs b/opentelemetry-sdk/src/logs/log_processor.rs index c7898933e5..ff0275a8e8 100644 --- a/opentelemetry-sdk/src/logs/log_processor.rs +++ b/opentelemetry-sdk/src/logs/log_processor.rs @@ -32,8 +32,7 @@ //! ``` use crate::{ - export::logs::{ExportResult, LogBatch, LogExporter}, - logs::{LogError, LogRecord, LogResult}, + logs::{ExportResult, LogBatch, LogError, LogExporter, LogRecord, LogResult}, Resource, }; use std::sync::mpsc::{self, RecvTimeoutError, SyncSender}; @@ -121,9 +120,8 @@ pub trait LogProcessor: Send + Sync + Debug { /// ### Using a SimpleLogProcessor /// /// ```rust -/// use opentelemetry_sdk::logs::{SimpleLogProcessor, LoggerProvider}; +/// use opentelemetry_sdk::logs::{SimpleLogProcessor, LoggerProvider, LogExporter}; /// use opentelemetry::global; -/// use opentelemetry_sdk::export::logs::LogExporter; /// use opentelemetry_sdk::testing::logs::InMemoryLogExporter; /// /// let exporter = InMemoryLogExporter::default(); // Replace with an actual exporter @@ -818,9 +816,8 @@ mod tests { BatchLogProcessor, OTEL_BLRP_EXPORT_TIMEOUT, OTEL_BLRP_MAX_EXPORT_BATCH_SIZE, OTEL_BLRP_MAX_QUEUE_SIZE, OTEL_BLRP_SCHEDULE_DELAY, }; - use crate::export::logs::{LogBatch, LogExporter}; - use crate::logs::LogRecord; use crate::logs::LogResult; + use crate::logs::{LogBatch, LogExporter, LogRecord}; use crate::testing::logs::InMemoryLogExporterBuilder; use crate::{ logs::{ 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 b5a3df2197..ccd918be5d 100644 --- a/opentelemetry-sdk/src/logs/log_processor_with_async_runtime.rs +++ b/opentelemetry-sdk/src/logs/log_processor_with_async_runtime.rs @@ -1,6 +1,5 @@ use crate::{ - export::logs::{ExportResult, LogBatch, LogExporter}, - logs::{LogError, LogRecord, LogResult}, + logs::{ExportResult, LogBatch, LogError, LogExporter, LogRecord, LogResult}, Resource, }; @@ -282,7 +281,6 @@ where #[cfg(all(test, feature = "testing", feature = "logs"))] mod tests { - use crate::export::logs::{LogBatch, LogExporter}; use crate::logs::log_processor::{ OTEL_BLRP_EXPORT_TIMEOUT, OTEL_BLRP_MAX_EXPORT_BATCH_SIZE, OTEL_BLRP_MAX_QUEUE_SIZE, OTEL_BLRP_SCHEDULE_DELAY, @@ -290,6 +288,7 @@ mod tests { use crate::logs::log_processor_with_async_runtime::BatchLogProcessor; use crate::logs::LogRecord; use crate::logs::LogResult; + use crate::logs::{LogBatch, LogExporter}; use crate::runtime; use crate::testing::logs::InMemoryLogExporterBuilder; use crate::{ diff --git a/opentelemetry-sdk/src/logs/mod.rs b/opentelemetry-sdk/src/logs/mod.rs index 97ae74ee85..9fa8824001 100644 --- a/opentelemetry-sdk/src/logs/mod.rs +++ b/opentelemetry-sdk/src/logs/mod.rs @@ -1,10 +1,12 @@ //! # OpenTelemetry Log SDK mod error; +mod export; mod log_emitter; mod log_processor; pub(crate) mod record; pub use error::{LogError, LogResult}; +pub use export::{ExportResult, LogBatch, LogExporter}; pub use log_emitter::{Builder, Logger, LoggerProvider}; pub use log_processor::{ BatchConfig, BatchConfigBuilder, BatchLogProcessor, BatchLogProcessorBuilder, LogProcessor, diff --git a/opentelemetry-sdk/src/metrics/internal/exponential_histogram.rs b/opentelemetry-sdk/src/metrics/internal/exponential_histogram.rs index 170f4a068d..995bc156e7 100644 --- a/opentelemetry-sdk/src/metrics/internal/exponential_histogram.rs +++ b/opentelemetry-sdk/src/metrics/internal/exponential_histogram.rs @@ -4,7 +4,7 @@ use opentelemetry::{otel_debug, KeyValue}; use std::sync::OnceLock; use crate::metrics::{ - data::{self, Aggregation}, + data::{self, Aggregation, ExponentialHistogram}, Temporality, }; @@ -386,7 +386,7 @@ impl ExpoHistogram { fn delta(&self, dest: Option<&mut dyn Aggregation>) -> (usize, Option>) { let time = self.init_time.delta(); - let h = dest.and_then(|d| d.as_mut().downcast_mut::>()); + let h = dest.and_then(|d| d.as_mut().downcast_mut::>()); let mut new_agg = if h.is_none() { Some(data::ExponentialHistogram { data_points: vec![], @@ -443,7 +443,7 @@ impl ExpoHistogram { ) -> (usize, Option>) { let time = self.init_time.cumulative(); - let h = dest.and_then(|d| d.as_mut().downcast_mut::>()); + let h = dest.and_then(|d| d.as_mut().downcast_mut::>()); let mut new_agg = if h.is_none() { Some(data::ExponentialHistogram { data_points: vec![], @@ -528,6 +528,7 @@ where mod tests { use std::{ops::Neg, time::SystemTime}; + use data::{ExponentialHistogram, Gauge, Histogram, Sum}; use tests::internal::AggregateFns; use crate::metrics::internal::{self, AggregateBuilder}; @@ -1468,8 +1469,8 @@ mod tests { test_name ); - if let Some(a) = a.as_any().downcast_ref::>() { - let b = b.as_any().downcast_ref::>().unwrap(); + if let Some(a) = a.as_any().downcast_ref::>() { + let b = b.as_any().downcast_ref::>().unwrap(); assert_eq!( a.data_points.len(), b.data_points.len(), @@ -1479,8 +1480,8 @@ mod tests { for (a, b) in a.data_points.iter().zip(b.data_points.iter()) { assert_gauge_data_points_eq(a, b, "mismatching gauge data points", test_name); } - } else if let Some(a) = a.as_any().downcast_ref::>() { - let b = b.as_any().downcast_ref::>().unwrap(); + } else if let Some(a) = a.as_any().downcast_ref::>() { + let b = b.as_any().downcast_ref::>().unwrap(); assert_eq!( a.temporality, b.temporality, "{} mismatching sum temporality", @@ -1500,8 +1501,8 @@ mod tests { for (a, b) in a.data_points.iter().zip(b.data_points.iter()) { assert_sum_data_points_eq(a, b, "mismatching sum data points", test_name); } - } else if let Some(a) = a.as_any().downcast_ref::>() { - let b = b.as_any().downcast_ref::>().unwrap(); + } else if let Some(a) = a.as_any().downcast_ref::>() { + let b = b.as_any().downcast_ref::>().unwrap(); assert_eq!( a.temporality, b.temporality, "{}: mismatching hist temporality", @@ -1516,10 +1517,10 @@ mod tests { for (a, b) in a.data_points.iter().zip(b.data_points.iter()) { assert_hist_data_points_eq(a, b, "mismatching hist data points", test_name); } - } else if let Some(a) = a.as_any().downcast_ref::>() { + } else if let Some(a) = a.as_any().downcast_ref::>() { let b = b .as_any() - .downcast_ref::>() + .downcast_ref::>() .unwrap(); assert_eq!( a.temporality, b.temporality, diff --git a/opentelemetry-sdk/src/metrics/internal/last_value.rs b/opentelemetry-sdk/src/metrics/internal/last_value.rs index cc2176b897..b14c86047e 100644 --- a/opentelemetry-sdk/src/metrics/internal/last_value.rs +++ b/opentelemetry-sdk/src/metrics/internal/last_value.rs @@ -1,5 +1,5 @@ use crate::metrics::{ - data::{self, Aggregation, GaugeDataPoint}, + data::{self, Aggregation, Gauge, GaugeDataPoint}, Temporality, }; use opentelemetry::KeyValue; @@ -65,7 +65,7 @@ impl LastValue { ) -> (usize, Option>) { let time = self.init_time.delta(); - let s_data = dest.and_then(|d| d.as_mut().downcast_mut::>()); + let s_data = dest.and_then(|d| d.as_mut().downcast_mut::>()); let mut new_agg = if s_data.is_none() { Some(data::Gauge { data_points: vec![], @@ -97,7 +97,7 @@ impl LastValue { dest: Option<&mut dyn Aggregation>, ) -> (usize, Option>) { let time = self.init_time.cumulative(); - let s_data = dest.and_then(|d| d.as_mut().downcast_mut::>()); + let s_data = dest.and_then(|d| d.as_mut().downcast_mut::>()); let mut new_agg = if s_data.is_none() { Some(data::Gauge { data_points: vec![], diff --git a/opentelemetry-sdk/src/metrics/internal/precomputed_sum.rs b/opentelemetry-sdk/src/metrics/internal/precomputed_sum.rs index b2f478e078..c035dbe696 100644 --- a/opentelemetry-sdk/src/metrics/internal/precomputed_sum.rs +++ b/opentelemetry-sdk/src/metrics/internal/precomputed_sum.rs @@ -1,6 +1,6 @@ use opentelemetry::KeyValue; -use crate::metrics::data::{self, Aggregation, SumDataPoint}; +use crate::metrics::data::{self, Aggregation, Sum, SumDataPoint}; use crate::metrics::Temporality; use super::aggregate::{AggregateTimeInitiator, AttributeSetFilter}; @@ -40,7 +40,7 @@ impl PrecomputedSum { ) -> (usize, Option>) { let time = self.init_time.delta(); - let s_data = dest.and_then(|d| d.as_mut().downcast_mut::>()); + let s_data = dest.and_then(|d| d.as_mut().downcast_mut::>()); let mut new_agg = if s_data.is_none() { Some(data::Sum { data_points: vec![], @@ -91,7 +91,7 @@ impl PrecomputedSum { ) -> (usize, Option>) { let time = self.init_time.cumulative(); - let s_data = dest.and_then(|d| d.as_mut().downcast_mut::>()); + let s_data = dest.and_then(|d| d.as_mut().downcast_mut::>()); let mut new_agg = if s_data.is_none() { Some(data::Sum { data_points: vec![], diff --git a/opentelemetry-sdk/src/metrics/mod.rs b/opentelemetry-sdk/src/metrics/mod.rs index a6a53a4f7a..51711daa3f 100644 --- a/opentelemetry-sdk/src/metrics/mod.rs +++ b/opentelemetry-sdk/src/metrics/mod.rs @@ -105,10 +105,14 @@ pub enum Temporality { mod tests { use self::data::{HistogramDataPoint, ScopeMetrics, SumDataPoint}; use super::*; + use crate::metrics::data::Aggregation; use crate::metrics::data::ResourceMetrics; use crate::testing::metrics::InMemoryMetricExporter; use crate::testing::metrics::InMemoryMetricExporterBuilder; + use data::Gauge; use data::GaugeDataPoint; + use data::Histogram; + use data::Sum; use opentelemetry::metrics::{Counter, Meter, UpDownCounter}; use opentelemetry::InstrumentationScope; use opentelemetry::{metrics::MeterProvider as _, KeyValue}; @@ -225,7 +229,7 @@ mod tests { counter.add(50, &[]); test_context.flush_metrics(); - let sum = test_context.get_aggregation::>("my_counter", None); + let sum = test_context.get_aggregation::>("my_counter", None); assert_eq!(sum.data_points.len(), 1, "Expected only one data point"); assert!(sum.is_monotonic, "Should produce monotonic."); @@ -248,7 +252,7 @@ mod tests { counter.add(50, &[]); test_context.flush_metrics(); - let sum = test_context.get_aggregation::>("my_counter", None); + let sum = test_context.get_aggregation::>("my_counter", None); assert_eq!(sum.data_points.len(), 1, "Expected only one data point"); assert!(sum.is_monotonic, "Should produce monotonic."); @@ -450,7 +454,7 @@ mod tests { for (iter, v) in values_clone.iter().enumerate() { test_context.flush_metrics(); - let sum = test_context.get_aggregation::>("my_observable_counter", None); + let sum = test_context.get_aggregation::>("my_observable_counter", None); assert_eq!(sum.data_points.len(), 1); assert!(sum.is_monotonic, "Counter should produce monotonic."); if let Temporality::Cumulative = temporality { @@ -567,7 +571,7 @@ mod tests { let sum = metric .data .as_any() - .downcast_ref::>() + .downcast_ref::>() .expect("Sum aggregation expected for Counter instruments by default"); // Expecting 1 time-series. @@ -633,7 +637,7 @@ mod tests { let sum1 = metric1 .data .as_any() - .downcast_ref::>() + .downcast_ref::>() .expect("Sum aggregation expected for Counter instruments by default"); // Expecting 1 time-series. @@ -653,7 +657,7 @@ mod tests { let sum2 = metric2 .data .as_any() - .downcast_ref::>() + .downcast_ref::>() .expect("Sum aggregation expected for Counter instruments by default"); // Expecting 1 time-series. @@ -737,7 +741,7 @@ mod tests { let sum = metric .data .as_any() - .downcast_ref::>() + .downcast_ref::>() .expect("Sum aggregation expected for Counter instruments by default"); // Expecting 1 time-series. @@ -757,7 +761,7 @@ mod tests { let reader = PeriodicReader::builder(exporter.clone()).build(); let criteria = Instrument::new().name("test_histogram"); let stream_invalid_aggregation = Stream::new() - .aggregation(Aggregation::ExplicitBucketHistogram { + .aggregation(aggregation::Aggregation::ExplicitBucketHistogram { boundaries: vec![0.9, 1.9, 1.2, 1.3, 1.4, 1.5], // invalid boundaries record_min_max: false, }) @@ -860,7 +864,7 @@ mod tests { let sum = metric .data .as_any() - .downcast_ref::>() + .downcast_ref::>() .expect("Sum aggregation expected for ObservableCounter instruments by default"); // Expecting 1 time-series only, as the view drops all attributes resulting @@ -937,7 +941,7 @@ mod tests { let sum = metric .data .as_any() - .downcast_ref::>() + .downcast_ref::>() .expect("Sum aggregation expected for Counter instruments by default"); // Expecting 1 time-series only, as the view drops all attributes resulting @@ -957,7 +961,7 @@ mod tests { counter.add(50, &[]); test_context.flush_metrics(); - let sum = test_context.get_aggregation::>("my_counter", Some("my_unit")); + let sum = test_context.get_aggregation::>("my_counter", Some("my_unit")); assert_eq!(sum.data_points.len(), 1, "Expected only one data point"); assert!(!sum.is_monotonic, "Should not produce monotonic."); @@ -980,7 +984,7 @@ mod tests { counter.add(50, &[]); test_context.flush_metrics(); - let sum = test_context.get_aggregation::>("my_counter", Some("my_unit")); + let sum = test_context.get_aggregation::>("my_counter", Some("my_unit")); assert_eq!(sum.data_points.len(), 1, "Expected only one data point"); assert!(!sum.is_monotonic, "Should not produce monotonic."); @@ -1002,12 +1006,12 @@ mod tests { counter.add(50, &[]); test_context.flush_metrics(); - let _ = test_context.get_aggregation::>("my_counter", None); + let _ = test_context.get_aggregation::>("my_counter", None); test_context.reset_metrics(); counter.add(5, &[]); test_context.flush_metrics(); - let sum = test_context.get_aggregation::>("my_counter", None); + let sum = test_context.get_aggregation::>("my_counter", None); assert_eq!(sum.data_points.len(), 1, "Expected only one data point"); assert!(sum.is_monotonic, "Should produce monotonic."); @@ -1029,12 +1033,12 @@ mod tests { counter.add(50, &[]); test_context.flush_metrics(); - let _ = test_context.get_aggregation::>("my_counter", None); + let _ = test_context.get_aggregation::>("my_counter", None); test_context.reset_metrics(); counter.add(5, &[]); test_context.flush_metrics(); - let sum = test_context.get_aggregation::>("my_counter", None); + let sum = test_context.get_aggregation::>("my_counter", None); assert_eq!(sum.data_points.len(), 1, "Expected only one data point"); assert!(sum.is_monotonic, "Should produce monotonic."); @@ -1056,12 +1060,12 @@ mod tests { counter.add(50, &[]); test_context.flush_metrics(); - let _ = test_context.get_aggregation::>("my_counter", None); + let _ = test_context.get_aggregation::>("my_counter", None); test_context.reset_metrics(); counter.add(50, &[KeyValue::new("a", "b")]); test_context.flush_metrics(); - let sum = test_context.get_aggregation::>("my_counter", None); + let sum = test_context.get_aggregation::>("my_counter", None); let no_attr_data_point = sum.data_points.iter().find(|x| x.attributes.is_empty()); @@ -1092,7 +1096,7 @@ mod tests { counter.add(1, &[KeyValue::new("key1", "value2")]); test_context.flush_metrics(); - let sum = test_context.get_aggregation::>("my_counter", None); + let sum = test_context.get_aggregation::>("my_counter", None); // Expecting 2 time-series. assert_eq!(sum.data_points.len(), 2); @@ -1217,7 +1221,7 @@ mod tests { match instrument_name { "counter" => { let counter_data = - test_context.get_aggregation::>("test_counter", None); + test_context.get_aggregation::>("test_counter", None); assert_eq!(counter_data.data_points.len(), 2); let zero_attribute_datapoint = find_sum_datapoint_with_no_attributes(&counter_data.data_points) @@ -1233,7 +1237,7 @@ mod tests { } "updown_counter" => { let updown_counter_data = - test_context.get_aggregation::>("test_updowncounter", None); + test_context.get_aggregation::>("test_updowncounter", None); assert_eq!(updown_counter_data.data_points.len(), 2); let zero_attribute_datapoint = find_sum_datapoint_with_no_attributes(&updown_counter_data.data_points) @@ -1248,8 +1252,8 @@ mod tests { assert_eq!(data_point1.value, 20); } "histogram" => { - let histogram_data = test_context - .get_aggregation::>("test_histogram", None); + let histogram_data = + test_context.get_aggregation::>("test_histogram", None); assert_eq!(histogram_data.data_points.len(), 2); let zero_attribute_datapoint = find_histogram_datapoint_with_no_attributes(&histogram_data.data_points) @@ -1270,8 +1274,7 @@ mod tests { assert_eq!(data_point1.max, Some(30)); } "gauge" => { - let gauge_data = - test_context.get_aggregation::>("test_gauge", None); + let gauge_data = test_context.get_aggregation::>("test_gauge", None); assert_eq!(gauge_data.data_points.len(), 2); let zero_attribute_datapoint = find_gauge_datapoint_with_no_attributes(&gauge_data.data_points) @@ -1370,7 +1373,7 @@ mod tests { match instrument_name { "counter" => { let counter_data = - test_context.get_aggregation::>("test_counter", None); + test_context.get_aggregation::>("test_counter", None); assert_eq!(counter_data.data_points.len(), 2); assert!(counter_data.is_monotonic); let zero_attribute_datapoint = @@ -1387,7 +1390,7 @@ mod tests { } "updown_counter" => { let updown_counter_data = - test_context.get_aggregation::>("test_updowncounter", None); + test_context.get_aggregation::>("test_updowncounter", None); assert_eq!(updown_counter_data.data_points.len(), 2); assert!(!updown_counter_data.is_monotonic); let zero_attribute_datapoint = @@ -1403,8 +1406,7 @@ mod tests { assert_eq!(data_point1.value, 20); } "gauge" => { - let gauge_data = - test_context.get_aggregation::>("test_gauge", None); + let gauge_data = test_context.get_aggregation::>("test_gauge", None); assert_eq!(gauge_data.data_points.len(), 2); let zero_attribute_datapoint = find_gauge_datapoint_with_no_attributes(&gauge_data.data_points) @@ -1453,8 +1455,7 @@ mod tests { // Assert // We invoke `test_context.flush_metrics()` six times. - let sums = - test_context.get_from_multiple_aggregations::>("my_counter", None, 6); + let sums = test_context.get_from_multiple_aggregations::>("my_counter", None, 6); let mut sum_zero_attributes = 0; let mut sum_key1_value1 = 0; @@ -1506,8 +1507,7 @@ mod tests { // Assert // We invoke `test_context.flush_metrics()` six times. - let sums = - test_context.get_from_multiple_aggregations::>("test_counter", None, 6); + let sums = test_context.get_from_multiple_aggregations::>("test_counter", None, 6); let mut sum_zero_attributes = 0.0; let mut sum_key1_value1 = 0.0; @@ -1560,7 +1560,7 @@ mod tests { // Assert // We invoke `test_context.flush_metrics()` six times. - let histograms = test_context.get_from_multiple_aggregations::>( + let histograms = test_context.get_from_multiple_aggregations::>( "test_histogram", None, 6, @@ -1697,7 +1697,7 @@ mod tests { // Assert // We invoke `test_context.flush_metrics()` six times. - let histograms = test_context.get_from_multiple_aggregations::>( + let histograms = test_context.get_from_multiple_aggregations::>( "test_histogram", None, 6, @@ -1827,8 +1827,7 @@ mod tests { test_context.flush_metrics(); // Assert - let histogram_data = - test_context.get_aggregation::>("my_histogram", None); + let histogram_data = test_context.get_aggregation::>("my_histogram", None); // Expecting 2 time-series. assert_eq!(histogram_data.data_points.len(), 2); if let Temporality::Cumulative = temporality { @@ -1874,8 +1873,7 @@ mod tests { test_context.flush_metrics(); - let histogram_data = - test_context.get_aggregation::>("my_histogram", None); + let histogram_data = test_context.get_aggregation::>("my_histogram", None); assert_eq!(histogram_data.data_points.len(), 2); let data_point1 = find_histogram_datapoint_with_key_value(&histogram_data.data_points, "key1", "value1") @@ -1924,8 +1922,7 @@ mod tests { test_context.flush_metrics(); // Assert - let histogram_data = - test_context.get_aggregation::>("test_histogram", None); + let histogram_data = test_context.get_aggregation::>("test_histogram", None); // Expecting 2 time-series. assert_eq!(histogram_data.data_points.len(), 1); if let Temporality::Cumulative = temporality { @@ -1978,7 +1975,7 @@ mod tests { test_context.flush_metrics(); // Assert - let gauge_data_point = test_context.get_aggregation::>("my_gauge", None); + let gauge_data_point = test_context.get_aggregation::>("my_gauge", None); // Expecting 2 time-series. assert_eq!(gauge_data_point.data_points.len(), 2); @@ -2007,7 +2004,7 @@ mod tests { test_context.flush_metrics(); - let gauge = test_context.get_aggregation::>("my_gauge", None); + let gauge = test_context.get_aggregation::>("my_gauge", None); assert_eq!(gauge.data_points.len(), 2); let data_point1 = find_gauge_datapoint_with_key_value(&gauge.data_points, "key1", "value1") .expect("datapoint with key1=value1 expected"); @@ -2036,7 +2033,7 @@ mod tests { test_context.flush_metrics(); // Assert - let gauge = test_context.get_aggregation::>("test_observable_gauge", None); + let gauge = test_context.get_aggregation::>("test_observable_gauge", None); // Expecting 2 time-series. let expected_time_series_count = if use_empty_attributes { 3 } else { 2 }; assert_eq!(gauge.data_points.len(), expected_time_series_count); @@ -2064,7 +2061,7 @@ mod tests { test_context.flush_metrics(); - let gauge = test_context.get_aggregation::>("test_observable_gauge", None); + let gauge = test_context.get_aggregation::>("test_observable_gauge", None); assert_eq!(gauge.data_points.len(), expected_time_series_count); if use_empty_attributes { @@ -2102,7 +2099,7 @@ mod tests { test_context.flush_metrics(); // Assert - let sum = test_context.get_aggregation::>("my_counter", None); + let sum = test_context.get_aggregation::>("my_counter", None); // Expecting 2 time-series. assert_eq!(sum.data_points.len(), 2); assert!(sum.is_monotonic, "Counter should produce monotonic."); @@ -2139,7 +2136,7 @@ mod tests { test_context.flush_metrics(); - let sum = test_context.get_aggregation::>("my_counter", None); + let sum = test_context.get_aggregation::>("my_counter", None); assert_eq!(sum.data_points.len(), 2); let data_point1 = find_sum_datapoint_with_key_value(&sum.data_points, "key1", "value1") .expect("datapoint with key1=value1 expected"); @@ -2179,7 +2176,7 @@ mod tests { counter.add(100, &[KeyValue::new("A", "yet_another")]); test_context.flush_metrics(); - let sum = test_context.get_aggregation::>("my_counter", None); + let sum = test_context.get_aggregation::>("my_counter", None); // Expecting 2002 metric points. (2000 + 1 overflow + Empty attributes) assert_eq!(sum.data_points.len(), 2002); @@ -2273,7 +2270,7 @@ mod tests { ); test_context.flush_metrics(); - let sum = test_context.get_aggregation::>("my_counter", None); + let sum = test_context.get_aggregation::>("my_counter", None); // Expecting 1 time-series. assert_eq!(sum.data_points.len(), 1); @@ -2302,7 +2299,7 @@ mod tests { test_context.flush_metrics(); // Assert - let sum = test_context.get_aggregation::>("my_updown_counter", None); + let sum = test_context.get_aggregation::>("my_updown_counter", None); // Expecting 2 time-series. assert_eq!(sum.data_points.len(), 2); assert!( @@ -2338,7 +2335,7 @@ mod tests { test_context.flush_metrics(); - let sum = test_context.get_aggregation::>("my_updown_counter", None); + let sum = test_context.get_aggregation::>("my_updown_counter", None); assert_eq!(sum.data_points.len(), 2); let data_point1 = find_sum_datapoint_with_key_value(&sum.data_points, "key1", "value1") .expect("datapoint with key1=value1 expected"); @@ -2493,7 +2490,7 @@ mod tests { assert!(resource_metrics.is_empty(), "no metrics should be exported"); } - fn get_aggregation( + fn get_aggregation( &mut self, counter_name: &str, unit_name: Option<&str>, @@ -2536,7 +2533,7 @@ mod tests { .expect("Failed to cast aggregation to expected type") } - fn get_from_multiple_aggregations( + fn get_from_multiple_aggregations( &mut self, counter_name: &str, unit_name: Option<&str>, diff --git a/opentelemetry-sdk/src/testing/logs/in_memory_exporter.rs b/opentelemetry-sdk/src/testing/logs/in_memory_exporter.rs index dff6d93c7e..a59b8e4c2d 100644 --- a/opentelemetry-sdk/src/testing/logs/in_memory_exporter.rs +++ b/opentelemetry-sdk/src/testing/logs/in_memory_exporter.rs @@ -1,6 +1,5 @@ -use crate::export::logs::{LogBatch, LogExporter}; use crate::logs::LogRecord; -use crate::logs::{LogError, LogResult}; +use crate::logs::{LogBatch, LogError, LogExporter, LogResult}; use crate::Resource; use opentelemetry::InstrumentationScope; use std::borrow::Cow; diff --git a/opentelemetry-sdk/src/testing/metrics/in_memory_exporter.rs b/opentelemetry-sdk/src/testing/metrics/in_memory_exporter.rs index 1d6f9c2754..e7774f2810 100644 --- a/opentelemetry-sdk/src/testing/metrics/in_memory_exporter.rs +++ b/opentelemetry-sdk/src/testing/metrics/in_memory_exporter.rs @@ -1,4 +1,4 @@ -use crate::metrics::data; +use crate::metrics::data::{self, Gauge, Sum}; use crate::metrics::data::{Histogram, Metric, ResourceMetrics, ScopeMetrics}; use crate::metrics::exporter::PushMetricExporter; use crate::metrics::MetricError; @@ -213,7 +213,7 @@ impl InMemoryMetricExporter { time: hist.time, temporality: hist.temporality, })) - } else if let Some(sum) = data.as_any().downcast_ref::>() { + } else if let Some(sum) = data.as_any().downcast_ref::>() { Some(Box::new(data::Sum { data_points: sum.data_points.clone(), start_time: sum.start_time, @@ -221,7 +221,7 @@ impl InMemoryMetricExporter { temporality: sum.temporality, is_monotonic: sum.is_monotonic, })) - } else if let Some(sum) = data.as_any().downcast_ref::>() { + } else if let Some(sum) = data.as_any().downcast_ref::>() { Some(Box::new(data::Sum { data_points: sum.data_points.clone(), start_time: sum.start_time, @@ -229,7 +229,7 @@ impl InMemoryMetricExporter { temporality: sum.temporality, is_monotonic: sum.is_monotonic, })) - } else if let Some(sum) = data.as_any().downcast_ref::>() { + } else if let Some(sum) = data.as_any().downcast_ref::>() { Some(Box::new(data::Sum { data_points: sum.data_points.clone(), start_time: sum.start_time, @@ -237,19 +237,19 @@ impl InMemoryMetricExporter { temporality: sum.temporality, is_monotonic: sum.is_monotonic, })) - } else if let Some(gauge) = data.as_any().downcast_ref::>() { + } else if let Some(gauge) = data.as_any().downcast_ref::>() { Some(Box::new(data::Gauge { data_points: gauge.data_points.clone(), start_time: gauge.start_time, time: gauge.time, })) - } else if let Some(gauge) = data.as_any().downcast_ref::>() { + } else if let Some(gauge) = data.as_any().downcast_ref::>() { Some(Box::new(data::Gauge { data_points: gauge.data_points.clone(), start_time: gauge.start_time, time: gauge.time, })) - } else if let Some(gauge) = data.as_any().downcast_ref::>() { + } else if let Some(gauge) = data.as_any().downcast_ref::>() { Some(Box::new(data::Gauge { data_points: gauge.data_points.clone(), start_time: gauge.start_time, diff --git a/opentelemetry-stdout/src/logs/exporter.rs b/opentelemetry-stdout/src/logs/exporter.rs index 6313474dd1..b4b1c56d9e 100644 --- a/opentelemetry-stdout/src/logs/exporter.rs +++ b/opentelemetry-stdout/src/logs/exporter.rs @@ -1,6 +1,6 @@ use chrono::{DateTime, Utc}; use core::fmt; -use opentelemetry_sdk::export::logs::LogBatch; +use opentelemetry_sdk::logs::LogBatch; use opentelemetry_sdk::logs::LogResult; use opentelemetry_sdk::Resource; use std::sync::atomic; @@ -29,7 +29,7 @@ impl fmt::Debug for LogExporter { } } -impl opentelemetry_sdk::export::logs::LogExporter for LogExporter { +impl opentelemetry_sdk::logs::LogExporter for LogExporter { /// Export spans to stdout #[allow(clippy::manual_async_fn)] fn export( diff --git a/opentelemetry-stdout/src/logs/mod.rs b/opentelemetry-stdout/src/logs/mod.rs index 76a8b1debe..8c48429366 100644 --- a/opentelemetry-stdout/src/logs/mod.rs +++ b/opentelemetry-stdout/src/logs/mod.rs @@ -2,7 +2,7 @@ //! //! The stdout [`LogExporter`] writes debug printed [`LogRecord`]s to Stdout. //! -//! [`LogExporter`]: opentelemetry_sdk::export::logs::LogExporter +//! [`LogExporter`]: opentelemetry_sdk::logs::LogExporter //! [`LogRecord`]: opentelemetry::logs::LogRecord mod exporter; pub use exporter::*; diff --git a/opentelemetry-stdout/src/metrics/exporter.rs b/opentelemetry-stdout/src/metrics/exporter.rs index 54feb33c41..839784755c 100644 --- a/opentelemetry-stdout/src/metrics/exporter.rs +++ b/opentelemetry-stdout/src/metrics/exporter.rs @@ -2,7 +2,10 @@ use async_trait::async_trait; use chrono::{DateTime, Utc}; use core::{f64, fmt}; use opentelemetry_sdk::metrics::{ - data::{self, ScopeMetrics}, + data::{ + ExponentialHistogram, Gauge, GaugeDataPoint, Histogram, HistogramDataPoint, + ResourceMetrics, ScopeMetrics, Sum, SumDataPoint, + }, exporter::PushMetricExporter, }; use opentelemetry_sdk::metrics::{MetricError, MetricResult, Temporality}; @@ -36,7 +39,7 @@ impl fmt::Debug for MetricExporter { #[async_trait] impl PushMetricExporter for MetricExporter { /// Write Metrics to stdout - async fn export(&self, metrics: &mut data::ResourceMetrics) -> MetricResult<()> { + async fn export(&self, metrics: &mut ResourceMetrics) -> MetricResult<()> { if self.is_shutdown.load(atomic::Ordering::SeqCst) { Err(MetricError::Other("exporter is shut down".into())) } else { @@ -97,34 +100,34 @@ fn print_metrics(metrics: &[ScopeMetrics]) { println!("\t\tUnit : {}", &metric.unit); let data = metric.data.as_any(); - if let Some(hist) = data.downcast_ref::>() { + if let Some(hist) = data.downcast_ref::>() { println!("\t\tType : Histogram"); print_histogram(hist); - } else if let Some(hist) = data.downcast_ref::>() { + } else if let Some(hist) = data.downcast_ref::>() { println!("\t\tType : Histogram"); print_histogram(hist); - } else if let Some(_hist) = data.downcast_ref::>() { + } else if let Some(_hist) = data.downcast_ref::>() { println!("\t\tType : Exponential Histogram"); // TODO - } else if let Some(_hist) = data.downcast_ref::>() { + } else if let Some(_hist) = data.downcast_ref::>() { println!("\t\tType : Exponential Histogram"); // TODO - } else if let Some(sum) = data.downcast_ref::>() { + } else if let Some(sum) = data.downcast_ref::>() { println!("\t\tType : Sum"); print_sum(sum); - } else if let Some(sum) = data.downcast_ref::>() { + } else if let Some(sum) = data.downcast_ref::>() { println!("\t\tType : Sum"); print_sum(sum); - } else if let Some(sum) = data.downcast_ref::>() { + } else if let Some(sum) = data.downcast_ref::>() { println!("\t\tType : Sum"); print_sum(sum); - } else if let Some(gauge) = data.downcast_ref::>() { + } else if let Some(gauge) = data.downcast_ref::>() { println!("\t\tType : Gauge"); print_gauge(gauge); - } else if let Some(gauge) = data.downcast_ref::>() { + } else if let Some(gauge) = data.downcast_ref::>() { println!("\t\tType : Gauge"); print_gauge(gauge); - } else if let Some(gauge) = data.downcast_ref::>() { + } else if let Some(gauge) = data.downcast_ref::>() { println!("\t\tType : Gauge"); print_gauge(gauge); } else { @@ -134,7 +137,7 @@ fn print_metrics(metrics: &[ScopeMetrics]) { } } -fn print_sum(sum: &data::Sum) { +fn print_sum(sum: &Sum) { println!("\t\tSum DataPoints"); println!("\t\tMonotonic : {}", sum.is_monotonic); if sum.temporality == Temporality::Cumulative { @@ -155,7 +158,7 @@ fn print_sum(sum: &data::Sum) { print_sum_data_points(&sum.data_points); } -fn print_gauge(gauge: &data::Gauge) { +fn print_gauge(gauge: &Gauge) { println!("\t\tGauge DataPoints"); if let Some(start_time) = gauge.start_time { let datetime: DateTime = start_time.into(); @@ -172,7 +175,7 @@ fn print_gauge(gauge: &data::Gauge) { print_gauge_data_points(&gauge.data_points); } -fn print_histogram(histogram: &data::Histogram) { +fn print_histogram(histogram: &Histogram) { if histogram.temporality == Temporality::Cumulative { println!("\t\tTemporality : Cumulative"); } else { @@ -192,7 +195,7 @@ fn print_histogram(histogram: &data::Histogram) { print_hist_data_points(&histogram.data_points); } -fn print_sum_data_points(data_points: &[data::SumDataPoint]) { +fn print_sum_data_points(data_points: &[SumDataPoint]) { for (i, data_point) in data_points.iter().enumerate() { println!("\t\tDataPoint #{}", i); println!("\t\t\tValue : {:#?}", data_point.value); @@ -203,7 +206,7 @@ fn print_sum_data_points(data_points: &[data::SumDataPoint]) { } } -fn print_gauge_data_points(data_points: &[data::GaugeDataPoint]) { +fn print_gauge_data_points(data_points: &[GaugeDataPoint]) { for (i, data_point) in data_points.iter().enumerate() { println!("\t\tDataPoint #{}", i); println!("\t\t\tValue : {:#?}", data_point.value); @@ -214,7 +217,7 @@ fn print_gauge_data_points(data_points: &[data::GaugeDataPoint]) { } } -fn print_hist_data_points(data_points: &[data::HistogramDataPoint]) { +fn print_hist_data_points(data_points: &[HistogramDataPoint]) { for (i, data_point) in data_points.iter().enumerate() { println!("\t\tDataPoint #{}", i); println!("\t\t\tCount : {}", data_point.count); diff --git a/stress/src/logs.rs b/stress/src/logs.rs index 2242d48eea..4119ac0d35 100644 --- a/stress/src/logs.rs +++ b/stress/src/logs.rs @@ -11,7 +11,7 @@ use opentelemetry::InstrumentationScope; use opentelemetry_appender_tracing::layer; -use opentelemetry_sdk::export::logs::{LogBatch, LogExporter}; +use opentelemetry_sdk::logs::{LogBatch, LogExporter}; use opentelemetry_sdk::logs::{LogProcessor, LogRecord, LogResult, LoggerProvider}; use tracing::error;