Skip to content

Commit 59c09b9

Browse files
authored
Merge branch 'main' into expose-builders
2 parents 664b19e + cc93ead commit 59c09b9

File tree

28 files changed

+1447
-296
lines changed

28 files changed

+1447
-296
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ jobs:
9898
with:
9999
toolchain: nightly-2024-06-30
100100
components: rustfmt
101+
- name: Patch dependencies versions
102+
run: bash ./scripts/patch_dependencies.sh
101103
- name: external-type-check
102104
run: |
103105
cargo install [email protected]
@@ -218,11 +220,11 @@ jobs:
218220
build-examples:
219221
runs-on: ubuntu-latest
220222
steps:
221-
- uses: actions/checkout@v4
222-
- uses: dtolnay/rust-toolchain@stable
223+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
224+
- uses: dtolnay/rust-toolchain@4305c38b25d97ef35a8ad1f985ccf2d2242004f2 # stable
223225
with:
224226
components: rustfmt
225-
- uses: arduino/setup-protoc@v3
227+
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
226228
with:
227229
repo-token: ${{ secrets.GITHUB_TOKEN }}
228230
- name: Build examples

examples/tracing-http-propagator/src/server.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use opentelemetry_sdk::{
1919
};
2020
use opentelemetry_semantic_conventions::trace;
2121
use opentelemetry_stdout::{LogExporter, SpanExporter};
22+
use std::time::Duration;
2223
use std::{convert::Infallible, net::SocketAddr, sync::OnceLock};
2324
use tokio::net::TcpListener;
2425
use tracing::info;
@@ -131,7 +132,7 @@ impl SpanProcessor for EnrichWithBaggageSpanProcessor {
131132
Ok(())
132133
}
133134

134-
fn shutdown(&self) -> OTelSdkResult {
135+
fn shutdown_with_timeout(&self, _timeout: Duration) -> OTelSdkResult {
135136
Ok(())
136137
}
137138

opentelemetry-proto/src/transform/metrics.rs

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,13 @@ pub mod tonic {
114114
fn from(rm: &ResourceMetrics) -> Self {
115115
ExportMetricsServiceRequest {
116116
resource_metrics: vec![TonicResourceMetrics {
117-
resource: Some((&rm.resource).into()),
118-
scope_metrics: rm.scope_metrics.iter().map(Into::into).collect(),
119-
schema_url: rm.resource.schema_url().map(Into::into).unwrap_or_default(),
117+
resource: Some((rm.resource()).into()),
118+
scope_metrics: rm.scope_metrics().map(Into::into).collect(),
119+
schema_url: rm
120+
.resource()
121+
.schema_url()
122+
.map(Into::into)
123+
.unwrap_or_default(),
120124
}],
121125
}
122126
}
@@ -135,10 +139,10 @@ pub mod tonic {
135139
impl From<&SdkScopeMetrics> for TonicScopeMetrics {
136140
fn from(sm: &SdkScopeMetrics) -> Self {
137141
TonicScopeMetrics {
138-
scope: Some((&sm.scope, None).into()),
139-
metrics: sm.metrics.iter().map(Into::into).collect(),
142+
scope: Some((sm.scope(), None).into()),
143+
metrics: sm.metrics().map(Into::into).collect(),
140144
schema_url: sm
141-
.scope
145+
.scope()
142146
.schema_url()
143147
.map(ToOwned::to_owned)
144148
.unwrap_or_default(),
@@ -149,11 +153,11 @@ pub mod tonic {
149153
impl From<&SdkMetric> for TonicMetric {
150154
fn from(metric: &SdkMetric) -> Self {
151155
TonicMetric {
152-
name: metric.name.to_string(),
153-
description: metric.description.to_string(),
154-
unit: metric.unit.to_string(),
156+
name: metric.name().to_string(),
157+
description: metric.description().to_string(),
158+
unit: metric.unit().to_string(),
155159
metadata: vec![], // internal and currently unused
156-
data: Some(match &metric.data {
160+
data: Some(match metric.data() {
157161
AggregatedMetrics::F64(data) => data.into(),
158162
AggregatedMetrics::U64(data) => data.into(),
159163
AggregatedMetrics::I64(data) => data.into(),
@@ -208,17 +212,16 @@ pub mod tonic {
208212
fn from(hist: &SdkHistogram<T>) -> Self {
209213
TonicHistogram {
210214
data_points: hist
211-
.data_points
212-
.iter()
215+
.data_points()
213216
.map(|dp| TonicHistogramDataPoint {
214-
attributes: dp.attributes.iter().map(Into::into).collect(),
217+
attributes: dp.attributes().map(Into::into).collect(),
215218
start_time_unix_nano: to_nanos(hist.start_time),
216219
time_unix_nano: to_nanos(hist.time),
217220
count: dp.count,
218221
sum: Some(dp.sum.into_f64()),
219-
bucket_counts: dp.bucket_counts.clone(),
220-
explicit_bounds: dp.bounds.clone(),
221-
exemplars: dp.exemplars.iter().map(Into::into).collect(),
222+
bucket_counts: dp.bucket_counts().collect(),
223+
explicit_bounds: dp.bounds().collect(),
224+
exemplars: dp.exemplars().map(Into::into).collect(),
222225
flags: TonicDataPointFlags::default() as u32,
223226
min: dp.min.map(Numeric::into_f64),
224227
max: dp.max.map(Numeric::into_f64),
@@ -236,10 +239,9 @@ pub mod tonic {
236239
fn from(hist: &SdkExponentialHistogram<T>) -> Self {
237240
TonicExponentialHistogram {
238241
data_points: hist
239-
.data_points
240-
.iter()
242+
.data_points()
241243
.map(|dp| TonicExponentialHistogramDataPoint {
242-
attributes: dp.attributes.iter().map(Into::into).collect(),
244+
attributes: dp.attributes().map(Into::into).collect(),
243245
start_time_unix_nano: to_nanos(hist.start_time),
244246
time_unix_nano: to_nanos(hist.time),
245247
count: dp.count as u64,
@@ -255,7 +257,7 @@ pub mod tonic {
255257
bucket_counts: dp.negative_bucket.counts.clone(),
256258
}),
257259
flags: TonicDataPointFlags::default() as u32,
258-
exemplars: dp.exemplars.iter().map(Into::into).collect(),
260+
exemplars: dp.exemplars().map(Into::into).collect(),
259261
min: dp.min.map(Numeric::into_f64),
260262
max: dp.max.map(Numeric::into_f64),
261263
zero_threshold: dp.zero_threshold,
@@ -273,13 +275,12 @@ pub mod tonic {
273275
fn from(sum: &SdkSum<T>) -> Self {
274276
TonicSum {
275277
data_points: sum
276-
.data_points
277-
.iter()
278+
.data_points()
278279
.map(|dp| TonicNumberDataPoint {
279-
attributes: dp.attributes.iter().map(Into::into).collect(),
280+
attributes: dp.attributes().map(Into::into).collect(),
280281
start_time_unix_nano: to_nanos(sum.start_time),
281282
time_unix_nano: to_nanos(sum.time),
282-
exemplars: dp.exemplars.iter().map(Into::into).collect(),
283+
exemplars: dp.exemplars().map(Into::into).collect(),
283284
flags: TonicDataPointFlags::default() as u32,
284285
value: Some(dp.value.into()),
285286
})
@@ -297,13 +298,12 @@ pub mod tonic {
297298
fn from(gauge: &SdkGauge<T>) -> Self {
298299
TonicGauge {
299300
data_points: gauge
300-
.data_points
301-
.iter()
301+
.data_points()
302302
.map(|dp| TonicNumberDataPoint {
303-
attributes: dp.attributes.iter().map(Into::into).collect(),
303+
attributes: dp.attributes().map(Into::into).collect(),
304304
start_time_unix_nano: gauge.start_time.map(to_nanos).unwrap_or_default(),
305305
time_unix_nano: to_nanos(gauge.time),
306-
exemplars: dp.exemplars.iter().map(Into::into).collect(),
306+
exemplars: dp.exemplars().map(Into::into).collect(),
307307
flags: TonicDataPointFlags::default() as u32,
308308
value: Some(dp.value.into()),
309309
})
@@ -319,8 +319,7 @@ pub mod tonic {
319319
fn from(ex: &SdkExemplar<T>) -> Self {
320320
TonicExemplar {
321321
filtered_attributes: ex
322-
.filtered_attributes
323-
.iter()
322+
.filtered_attributes()
324323
.map(|kv| (&kv.key, &kv.value).into())
325324
.collect(),
326325
time_unix_nano: to_nanos(ex.time),

opentelemetry-sdk/CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ also modified to suppress telemetry before invoking exporters.
2525
- Fixed the overflow attribute to correctly use the boolean value `true`
2626
instead of the string `"true"`.
2727
[#2878](https://github.com/open-telemetry/opentelemetry-rust/issues/2878)
28+
- The `shutdown_with_timeout` method is added to SpanProcessor, SpanExporter trait and TracerProvider.
2829
- The `shutdown_with_timeout` method is added to LogExporter trait.
2930
- The `shutdown_with_timeout` method is added to LogProvider and LogProcessor trait.
3031
- *Breaking* `MetricError`, `MetricResult` no longer public (except when
@@ -41,12 +42,39 @@ also modified to suppress telemetry before invoking exporters.
4142
behind feature flag "experimental_metrics_custom_reader".
4243
[#2928](https://github.com/open-telemetry/opentelemetry-rust/pull/2928)
4344

45+
- TODO: Placeholder for View related changelog. Polish this after all
46+
changes are done.
47+
Hide public fields from `Stream` struct.
48+
4449
- *Breaking* `Aggregation` enum moved behind feature flag
4550
"spec_unstable_metrics_views". This was only required when using Views.
4651
[#2928](https://github.com/open-telemetry/opentelemetry-rust/pull/2928)
4752
- *Breaking* change, affecting custom `PushMetricExporter` authors:
4853
- The `export` method on `PushMetricExporter` now accepts `&ResourceMetrics`
4954
instead of `&mut ResourceMetrics`.
55+
- `ResourceMetrics` no longer exposes `scope_metrics` field, but instead
56+
offers `scope_metrics()` method that returns an iterator over the same.
57+
- `ScopeMetrics` no longer exposes `metrics` field, but instead offers
58+
`metrics()` method that returns an iterator over the same.
59+
- `Sum`, `Gauge`, `Histogram` & `ExponentialHistogram` no longer exposes
60+
`data_points` field, but instead offers `data_points()` method that returns
61+
an iterator over the same.
62+
- `SumDataPoint`, `GaugeDataPoint`, `HistogramDataPoint` &
63+
`ExponentialHistogramDataPoint` no longer exposes `attributes`, `exemplars`
64+
field, but instead offers `attributes()`, and `exemplars()` method that
65+
returns an iterator over the same.
66+
- `Exemplar` no longer exposes `filtered_attributes` field, but instead
67+
offers `filtered_attributes()` method that returns an iterator over
68+
the same.
69+
- `HistogramDataPoint` no longer exposes `bounds` and `bucket_counts`, but
70+
instead offers `bounds()` and `bucket_counts()` methods that returns an
71+
iterator over the same.
72+
- `Metric` no longer exposes `name`, `description`, `unit`, `data` fields, but
73+
instead offers `name()`, `description()`, `unit()`, and `data()` accessor methods.
74+
- `ResourceMetrics` no longer exposes `resource` field, but instead offers
75+
a `resource()` accessor method.
76+
- `ScopeMetrics` no longer exposes `scope` field, but instead offers
77+
a `scope()` accessor method.
5078

5179
## 0.29.0
5280

opentelemetry-sdk/benches/metric.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use opentelemetry_sdk::{
99
data::ResourceMetrics, new_view, reader::MetricReader, Aggregation, Instrument,
1010
InstrumentKind, ManualReader, Pipeline, SdkMeterProvider, Stream, Temporality, View,
1111
},
12-
Resource,
1312
};
1413
use rand::Rng;
1514
use std::sync::{Arc, Weak};
@@ -240,10 +239,7 @@ fn counters(c: &mut Criterion) {
240239
});
241240

242241
let (rdr, cntr) = bench_counter(None, "cumulative");
243-
let mut rm = ResourceMetrics {
244-
resource: Resource::builder_empty().build(),
245-
scope_metrics: Vec::new(),
246-
};
242+
let mut rm = ResourceMetrics::default();
247243

248244
group.bench_function("CollectOneAttr", |b| {
249245
let mut v = 0;
@@ -337,10 +333,7 @@ fn benchmark_collect_histogram(b: &mut Bencher, n: usize) {
337333
h.record(1, &[]);
338334
}
339335

340-
let mut rm = ResourceMetrics {
341-
resource: Resource::builder_empty().build(),
342-
scope_metrics: Vec::new(),
343-
};
336+
let mut rm = ResourceMetrics::default();
344337

345338
b.iter(|| {
346339
let _ = r.collect(&mut rm);

opentelemetry-sdk/src/logs/batch_log_processor.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ type LogsData = Box<(SdkLogRecord, InstrumentationScope)>;
101101
/// cause deadlock. Instead, call `shutdown()` from a separate thread or use
102102
/// tokio's `spawn_blocking`.
103103
///
104-
/// [`shutdown()`]: crate::logs::LoggerProvider::shutdown
105-
/// [`force_flush()`]: crate::logs::LoggerProvider::force_flush
106104
///
107105
/// ### Using a BatchLogProcessor:
108106
///

opentelemetry-sdk/src/metrics/aggregation.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,8 @@ impl Aggregation {
151151
#[cfg(test)]
152152
mod tests {
153153
use crate::metrics::error::{MetricError, MetricResult};
154-
use crate::metrics::{
155-
internal::{EXPO_MAX_SCALE, EXPO_MIN_SCALE},
156-
Aggregation,
157-
};
154+
use crate::metrics::internal::{EXPO_MAX_SCALE, EXPO_MIN_SCALE};
155+
use crate::metrics::Aggregation;
158156

159157
#[test]
160158
fn validate_aggregation() {

0 commit comments

Comments
 (0)