Skip to content

Commit 4ce7655

Browse files
authored
feat: Hide MetricReader and friends (open-telemetry#2928)
1 parent 64cf291 commit 4ce7655

File tree

11 files changed

+36
-15
lines changed

11 files changed

+36
-15
lines changed

opentelemetry-sdk/CHANGELOG.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,22 @@ also modified to suppress telemetry before invoking exporters.
2323
- Fixed the overflow attribute to correctly use the boolean value `true`
2424
instead of the string `"true"`.
2525
[#2878](https://github.com/open-telemetry/opentelemetry-rust/issues/2878)
26-
27-
- *Breaking* change for custom `MetricReader` authors.
28-
The `shutdown_with_timeout` method is added to `MetricReader` trait.
29-
`collect` method on `MetricReader` modified to return `OTelSdkResult`.
30-
[#2905](https://github.com/open-telemetry/opentelemetry-rust/pull/2905)
3126
- *Breaking* `MetricError`, `MetricResult` no longer public (except when
3227
`spec_unstable_metrics_views` feature flag is enabled). `OTelSdkResult` should
3328
be used instead, wherever applicable.
29+
- *Breaking* change, affecting custom MetricReader authors: The
30+
`shutdown_with_timeout` method is added to `MetricReader` trait. `collect`
31+
method on `MetricReader` modified to return `OTelSdkResult`.
32+
[#2905](https://github.com/open-telemetry/opentelemetry-rust/pull/2905)
3433
[#2905](https://github.com/open-telemetry/opentelemetry-rust/pull/2905)
34+
- *Breaking* change, affecting custom MetricReader authors: `MetricReader`
35+
trait, `ManualReader` struct, `Pipeline` struct, `InstrumentKind` enum moved
36+
behind feature flag "experimental_metrics_custom_reader". These were only
37+
required for writing custom readers.
38+
[2928](https://github.com/open-telemetry/opentelemetry-rust/pull/2928)
39+
- *Breaking* `Aggregation` enum moved behind feature flag
40+
"spec_unstable_metrics_views". This was only required when using Views.
41+
[2928](https://github.com/open-telemetry/opentelemetry-rust/pull/2928)
3542

3643
## 0.29.0
3744

opentelemetry-sdk/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ rt-tokio-current-thread = ["tokio", "tokio-stream", "experimental_async_runtime"
5353
internal-logs = ["opentelemetry/internal-logs"]
5454
experimental_metrics_periodicreader_with_async_runtime = ["metrics", "experimental_async_runtime"]
5555
spec_unstable_metrics_views = ["metrics"]
56+
experimental_metrics_custom_reader = ["metrics"]
5657
experimental_logs_batch_log_processor_with_async_runtime = ["logs", "experimental_async_runtime"]
5758
experimental_logs_concurrent_log_processor = ["logs"]
5859
experimental_trace_batch_span_processor_with_async_runtime = ["trace", "experimental_async_runtime"]
@@ -107,7 +108,7 @@ required-features = ["testing"]
107108
[[bench]]
108109
name = "metric"
109110
harness = false
110-
required-features = ["metrics", "spec_unstable_metrics_views"]
111+
required-features = ["metrics", "spec_unstable_metrics_views", "experimental_metrics_custom_reader"]
111112

112113
[[bench]]
113114
name = "log"

opentelemetry-sdk/src/metrics/meter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ where
696696
mod tests {
697697
use std::borrow::Cow;
698698

699-
use crate::metrics::MetricError;
699+
use crate::metrics::error::MetricError;
700700

701701
use super::{
702702
validate_instrument_name, validate_instrument_unit, INSTRUMENT_NAME_EMPTY,

opentelemetry-sdk/src/metrics/meter_provider.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use crate::error::OTelSdkResult;
1616
use crate::Resource;
1717

1818
use super::{
19-
exporter::PushMetricExporter, meter::SdkMeter, noop::NoopMeter, pipeline::Pipelines,
20-
reader::MetricReader, view::View, PeriodicReader,
19+
exporter::PushMetricExporter, meter::SdkMeter, noop::NoopMeter,
20+
periodic_reader::PeriodicReader, pipeline::Pipelines, reader::MetricReader, view::View,
2121
};
2222

2323
/// Handles the creation and coordination of [Meter]s.

opentelemetry-sdk/src/metrics/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@
3939
//!
4040
//! [Resource]: crate::Resource
4141
42+
#[allow(unreachable_pub)]
43+
#[allow(unused)]
4244
pub(crate) mod aggregation;
4345
pub mod data;
4446
mod error;
4547
pub mod exporter;
4648
pub(crate) mod instrument;
4749
pub(crate) mod internal;
50+
#[cfg(feature = "experimental_metrics_custom_reader")]
4851
pub(crate) mod manual_reader;
4952
pub(crate) mod meter;
5053
mod meter_provider;
@@ -54,7 +57,10 @@ pub(crate) mod periodic_reader;
5457
/// Module for periodic reader with async runtime.
5558
pub mod periodic_reader_with_async_runtime;
5659
pub(crate) mod pipeline;
60+
#[cfg(feature = "experimental_metrics_custom_reader")]
5761
pub mod reader;
62+
#[cfg(not(feature = "experimental_metrics_custom_reader"))]
63+
pub(crate) mod reader;
5864
pub(crate) mod view;
5965

6066
/// In-Memory metric exporter for testing purpose.
@@ -65,14 +71,18 @@ pub mod in_memory_exporter;
6571
#[cfg_attr(docsrs, doc(cfg(any(feature = "testing", test))))]
6672
pub use in_memory_exporter::{InMemoryMetricExporter, InMemoryMetricExporterBuilder};
6773

74+
#[cfg(feature = "spec_unstable_metrics_views")]
6875
pub use aggregation::*;
6976
#[cfg(feature = "spec_unstable_metrics_views")]
7077
pub use error::{MetricError, MetricResult};
78+
#[cfg(feature = "experimental_metrics_custom_reader")]
7179
pub use manual_reader::*;
7280
pub use meter_provider::*;
7381
pub use periodic_reader::*;
82+
#[cfg(feature = "experimental_metrics_custom_reader")]
7483
pub use pipeline::Pipeline;
7584

85+
#[cfg(feature = "experimental_metrics_custom_reader")]
7686
pub use instrument::InstrumentKind;
7787

7888
#[cfg(feature = "spec_unstable_metrics_views")]

opentelemetry-sdk/src/metrics/periodic_reader.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ use crate::{
1717
};
1818

1919
use super::{
20-
data::ResourceMetrics, instrument::InstrumentKind, reader::MetricReader, Pipeline, Temporality,
20+
data::ResourceMetrics, instrument::InstrumentKind, pipeline::Pipeline, reader::MetricReader,
21+
Temporality,
2122
};
2223

2324
const DEFAULT_INTERVAL: Duration = Duration::from_secs(60);

opentelemetry-sdk/src/metrics/periodic_reader_with_async_runtime.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ use crate::{
2020
Resource,
2121
};
2222

23-
use super::{data::ResourceMetrics, reader::MetricReader, InstrumentKind, Pipeline};
23+
use super::{
24+
data::ResourceMetrics, instrument::InstrumentKind, pipeline::Pipeline, reader::MetricReader,
25+
};
2426

2527
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(30);
2628
const DEFAULT_INTERVAL: Duration = Duration::from_secs(60);

opentelemetry-sdk/src/metrics/pipeline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::{
2323

2424
use self::internal::AggregateFns;
2525

26-
use super::{Aggregation, Temporality};
26+
use super::{aggregation::Aggregation, Temporality};
2727

2828
/// Connects all of the instruments created by a meter provider to a [MetricReader].
2929
///

opentelemetry-sdk/src/metrics/reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::error::OTelSdkResult;
33
use std::time::Duration;
44
use std::{fmt, sync::Weak};
55

6-
use super::{data::ResourceMetrics, pipeline::Pipeline, InstrumentKind, Temporality};
6+
use super::{data::ResourceMetrics, instrument::InstrumentKind, pipeline::Pipeline, Temporality};
77

88
/// The interface used between the SDK and an exporter.
99
///

opentelemetry-sdk/src/testing/metrics/metric_reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::error::{OTelSdkError, OTelSdkResult};
22
use crate::metrics::Temporality;
33
use crate::metrics::{
4-
data::ResourceMetrics, pipeline::Pipeline, reader::MetricReader, InstrumentKind,
4+
data::ResourceMetrics, instrument::InstrumentKind, pipeline::Pipeline, reader::MetricReader,
55
};
66
use std::sync::{Arc, Mutex, Weak};
77
use std::time::Duration;

stress/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ctrlc = { workspace = true }
5252
lazy_static = { workspace = true }
5353
num_cpus = { workspace = true }
5454
opentelemetry = { path = "../opentelemetry", features = ["metrics", "logs", "trace", "spec_unstable_logs_enabled"] }
55-
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = ["metrics", "logs", "trace", "spec_unstable_logs_enabled", "experimental_logs_concurrent_log_processor"] }
55+
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = ["metrics", "logs", "trace", "spec_unstable_logs_enabled", "experimental_logs_concurrent_log_processor", "experimental_metrics_custom_reader"] }
5656
opentelemetry-appender-tracing = { workspace = true, features = ["spec_unstable_logs_enabled"] }
5757
rand = { workspace = true, features = ["small_rng", "os_rng"] }
5858
tracing = { workspace = true, features = ["std"]}

0 commit comments

Comments
 (0)