Skip to content

Commit d0b94ce

Browse files
authored
Merge branch 'main' into appender-tracing-fix-trace-context
2 parents 3aa5bdf + 38be4d9 commit d0b94ce

File tree

11 files changed

+125
-116
lines changed

11 files changed

+125
-116
lines changed

opentelemetry-otlp/src/exporter/http/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ use std::time::Duration;
2727
#[cfg(feature = "metrics")]
2828
mod metrics;
2929

30+
#[cfg(feature = "metrics")]
31+
use opentelemetry_sdk::metrics::data::ResourceMetrics;
32+
3033
#[cfg(feature = "logs")]
3134
pub(crate) mod logs;
3235

@@ -336,7 +339,7 @@ impl OtlpHttpClient {
336339
#[cfg(feature = "metrics")]
337340
fn build_metrics_export_body(
338341
&self,
339-
metrics: &mut opentelemetry_sdk::metrics::data::ResourceMetrics,
342+
metrics: &mut ResourceMetrics,
340343
) -> opentelemetry_sdk::metrics::MetricResult<(Vec<u8>, &'static str)> {
341344
use opentelemetry_proto::tonic::collector::metrics::v1::ExportMetricsServiceRequest;
342345

opentelemetry-proto/src/transform/metrics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ pub mod tonic {
1010

1111
use opentelemetry::{otel_debug, Key, Value};
1212
use opentelemetry_sdk::metrics::data::{
13-
self, Exemplar as SdkExemplar, ExponentialHistogram as SdkExponentialHistogram,
14-
Gauge as SdkGauge, Histogram as SdkHistogram, Metric as SdkMetric,
13+
Exemplar as SdkExemplar, ExponentialHistogram as SdkExponentialHistogram,
14+
Gauge as SdkGauge, Histogram as SdkHistogram, Metric as SdkMetric, ResourceMetrics,
1515
ScopeMetrics as SdkScopeMetrics, Sum as SdkSum,
1616
};
1717
use opentelemetry_sdk::metrics::Temporality;
@@ -110,8 +110,8 @@ pub mod tonic {
110110
}
111111
}
112112

113-
impl From<&data::ResourceMetrics> for ExportMetricsServiceRequest {
114-
fn from(rm: &data::ResourceMetrics) -> Self {
113+
impl From<&ResourceMetrics> for ExportMetricsServiceRequest {
114+
fn from(rm: &ResourceMetrics) -> Self {
115115
ExportMetricsServiceRequest {
116116
resource_metrics: vec![TonicResourceMetrics {
117117
resource: Some((&rm.resource).into()),

opentelemetry-sdk/CHANGELOG.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- *Feature*: Add `ResourceBuilder` for an easy way to create new `Resource`s
1818
- *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.
1919
Example Usage:
20+
2021
```rust
2122
// old
2223
Resource::default().with_attributes([
@@ -30,6 +31,7 @@
3031
.with_attribute(KeyValue::new("key", "value"))
3132
.build();
3233
```
34+
3335
- *Breaking* The LogExporter::export() method no longer requires a mutable reference to self.:
3436
Before:
3537
async fn export(&mut self, _batch: LogBatch<'_>) -> LogResult<()>
@@ -61,15 +63,18 @@
6163
1. *Default Implementation, requires no async runtime* (**Recommended**) The
6264
new default implementation does not require a runtime argument. Replace the
6365
builder method accordingly:
64-
- *Before:*
65-
```rust
66-
let reader = opentelemetry_sdk::metrics::PeriodicReader::builder(exporter, runtime::Tokio).build();
67-
```
68-
- *After:*
69-
```rust
70-
let reader = opentelemetry_sdk::metrics::PeriodicReader::builder(exporter).build();
66+
*Before:*
67+
68+
```rust
69+
let reader = opentelemetry_sdk::metrics::PeriodicReader::builder(exporter, runtime::Tokio).build();
7170
```
7271

72+
*After:*
73+
74+
```rust
75+
let reader = opentelemetry_sdk::metrics::PeriodicReader::builder(exporter).build();
76+
```
77+
7378
The new PeriodicReader can be used with OTLP Exporter, and supports
7479
following exporter features:
7580
- `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
250255
equal signs (`"="`). [#2120](https://github.com/open-telemetry/opentelemetry-rust/pull/2120)
251256

252257
- **Breaking** Introduced `experimental_async_runtime` feature for runtime-specific traits.
253-
- Runtime-specific features (`rt-tokio`, `rt-tokio-current-thread`, and `rt-async-std`)
258+
- Runtime-specific features (`rt-tokio`, `rt-tokio-current-thread`, and `rt-async-std`)
254259
now depend on the `experimental_async_runtime` feature.
255-
- For most users, no action is required. Enabling runtime features such as `rt-tokio`, `rt-tokio-current-thread`,
260+
- For most users, no action is required. Enabling runtime features such as `rt-tokio`, `rt-tokio-current-thread`,
256261
or `rt-async-std` will automatically enable the `experimental_async_runtime` feature.
257-
- If you're implementing a custom runtime, you must explicitly enable the experimental_async_runtime` feature in your
262+
- If you're implementing a custom runtime, you must explicitly enable the experimental_async_runtime` feature in your
258263
Cargo.toml and implement the required `Runtime` traits.
259264

260265
- Removed Metrics Cardinality Limit feature. This was originally introduced in
@@ -263,12 +268,11 @@ hardcoded limit of 2000 and no ability to change it. This feature will be
263268
re-introduced in a future date, along with the ability to change the cardinality
264269
limit.
265270

266-
- Refactor modules. This is *Breaking* change, if you author custom
267-
LogExporter,LogProcessor.
271+
- *Breaking (Affects custom LogExporter, LogProcessor authors only)*: Rename namespaces
268272
before:
269273
`opentelemetry_sdk::export::logs::{ExportResult, LogBatch, LogExporter};`
270274
now:
271-
`opentelemetry_sdk::logs::{ExportResult, LogBatch, LogExporter}`
275+
`opentelemetry_sdk::logs::{ExportResult, LogBatch, LogExporter};`
272276

273277
## 0.27.1
274278

@@ -278,6 +282,7 @@ Released 2024-Nov-27
278282
- `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.
279283
`trace::Config` is scheduled to be removed from public API in `v0.28.0`.
280284
example:
285+
281286
```rust
282287
// old
283288
let tracer_provider: TracerProvider = TracerProvider::builder()
@@ -289,6 +294,7 @@ Released 2024-Nov-27
289294
.with_resource(Resource::empty())
290295
.build();
291296
```
297+
292298
- `logs::LogData` struct is deprecated, and scheduled to be removed from public API in `v0.28.0`.
293299
- Bug fix: Empty Meter names are retained as-is instead of replacing with
294300
"rust.opentelemetry.io/sdk/meter"

opentelemetry-sdk/src/logs/log_emitter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{BatchLogProcessor, LogProcessor, LogRecord, SimpleLogProcessor, TraceContext};
2+
use crate::logs::{LogError, LogExporter, LogResult};
23
use crate::Resource;
3-
use crate::{logs::LogError, logs::LogExporter, logs::LogResult};
44
use opentelemetry::{otel_debug, otel_info, trace::TraceContextExt, Context, InstrumentationScope};
55

66
#[cfg(feature = "spec_unstable_logs_enabled")]

opentelemetry-sdk/src/logs/log_processor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,8 @@ pub trait LogProcessor: Send + Sync + Debug {
120120
/// ### Using a SimpleLogProcessor
121121
///
122122
/// ```rust
123-
/// use opentelemetry_sdk::logs::{SimpleLogProcessor, LoggerProvider};
123+
/// use opentelemetry_sdk::logs::{SimpleLogProcessor, LoggerProvider, LogExporter};
124124
/// use opentelemetry::global;
125-
/// use opentelemetry_sdk::logs::LogExporter;
126125
/// use opentelemetry_sdk::testing::logs::InMemoryLogExporter;
127126
///
128127
/// let exporter = InMemoryLogExporter::default(); // Replace with an actual exporter

opentelemetry-sdk/src/metrics/internal/exponential_histogram.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use opentelemetry::{otel_debug, KeyValue};
44
use std::sync::OnceLock;
55

66
use crate::metrics::{
7-
data::{self, Aggregation},
7+
data::{self, Aggregation, ExponentialHistogram},
88
Temporality,
99
};
1010

@@ -386,7 +386,7 @@ impl<T: Number> ExpoHistogram<T> {
386386
fn delta(&self, dest: Option<&mut dyn Aggregation>) -> (usize, Option<Box<dyn Aggregation>>) {
387387
let time = self.init_time.delta();
388388

389-
let h = dest.and_then(|d| d.as_mut().downcast_mut::<data::ExponentialHistogram<T>>());
389+
let h = dest.and_then(|d| d.as_mut().downcast_mut::<ExponentialHistogram<T>>());
390390
let mut new_agg = if h.is_none() {
391391
Some(data::ExponentialHistogram {
392392
data_points: vec![],
@@ -443,7 +443,7 @@ impl<T: Number> ExpoHistogram<T> {
443443
) -> (usize, Option<Box<dyn Aggregation>>) {
444444
let time = self.init_time.cumulative();
445445

446-
let h = dest.and_then(|d| d.as_mut().downcast_mut::<data::ExponentialHistogram<T>>());
446+
let h = dest.and_then(|d| d.as_mut().downcast_mut::<ExponentialHistogram<T>>());
447447
let mut new_agg = if h.is_none() {
448448
Some(data::ExponentialHistogram {
449449
data_points: vec![],
@@ -528,6 +528,7 @@ where
528528
mod tests {
529529
use std::{ops::Neg, time::SystemTime};
530530

531+
use data::{ExponentialHistogram, Gauge, Histogram, Sum};
531532
use tests::internal::AggregateFns;
532533

533534
use crate::metrics::internal::{self, AggregateBuilder};
@@ -1468,8 +1469,8 @@ mod tests {
14681469
test_name
14691470
);
14701471

1471-
if let Some(a) = a.as_any().downcast_ref::<data::Gauge<T>>() {
1472-
let b = b.as_any().downcast_ref::<data::Gauge<T>>().unwrap();
1472+
if let Some(a) = a.as_any().downcast_ref::<Gauge<T>>() {
1473+
let b = b.as_any().downcast_ref::<Gauge<T>>().unwrap();
14731474
assert_eq!(
14741475
a.data_points.len(),
14751476
b.data_points.len(),
@@ -1479,8 +1480,8 @@ mod tests {
14791480
for (a, b) in a.data_points.iter().zip(b.data_points.iter()) {
14801481
assert_gauge_data_points_eq(a, b, "mismatching gauge data points", test_name);
14811482
}
1482-
} else if let Some(a) = a.as_any().downcast_ref::<data::Sum<T>>() {
1483-
let b = b.as_any().downcast_ref::<data::Sum<T>>().unwrap();
1483+
} else if let Some(a) = a.as_any().downcast_ref::<Sum<T>>() {
1484+
let b = b.as_any().downcast_ref::<Sum<T>>().unwrap();
14841485
assert_eq!(
14851486
a.temporality, b.temporality,
14861487
"{} mismatching sum temporality",
@@ -1500,8 +1501,8 @@ mod tests {
15001501
for (a, b) in a.data_points.iter().zip(b.data_points.iter()) {
15011502
assert_sum_data_points_eq(a, b, "mismatching sum data points", test_name);
15021503
}
1503-
} else if let Some(a) = a.as_any().downcast_ref::<data::Histogram<T>>() {
1504-
let b = b.as_any().downcast_ref::<data::Histogram<T>>().unwrap();
1504+
} else if let Some(a) = a.as_any().downcast_ref::<Histogram<T>>() {
1505+
let b = b.as_any().downcast_ref::<Histogram<T>>().unwrap();
15051506
assert_eq!(
15061507
a.temporality, b.temporality,
15071508
"{}: mismatching hist temporality",
@@ -1516,10 +1517,10 @@ mod tests {
15161517
for (a, b) in a.data_points.iter().zip(b.data_points.iter()) {
15171518
assert_hist_data_points_eq(a, b, "mismatching hist data points", test_name);
15181519
}
1519-
} else if let Some(a) = a.as_any().downcast_ref::<data::ExponentialHistogram<T>>() {
1520+
} else if let Some(a) = a.as_any().downcast_ref::<ExponentialHistogram<T>>() {
15201521
let b = b
15211522
.as_any()
1522-
.downcast_ref::<data::ExponentialHistogram<T>>()
1523+
.downcast_ref::<ExponentialHistogram<T>>()
15231524
.unwrap();
15241525
assert_eq!(
15251526
a.temporality, b.temporality,

opentelemetry-sdk/src/metrics/internal/last_value.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::metrics::{
2-
data::{self, Aggregation, GaugeDataPoint},
2+
data::{self, Aggregation, Gauge, GaugeDataPoint},
33
Temporality,
44
};
55
use opentelemetry::KeyValue;
@@ -65,7 +65,7 @@ impl<T: Number> LastValue<T> {
6565
) -> (usize, Option<Box<dyn Aggregation>>) {
6666
let time = self.init_time.delta();
6767

68-
let s_data = dest.and_then(|d| d.as_mut().downcast_mut::<data::Gauge<T>>());
68+
let s_data = dest.and_then(|d| d.as_mut().downcast_mut::<Gauge<T>>());
6969
let mut new_agg = if s_data.is_none() {
7070
Some(data::Gauge {
7171
data_points: vec![],
@@ -97,7 +97,7 @@ impl<T: Number> LastValue<T> {
9797
dest: Option<&mut dyn Aggregation>,
9898
) -> (usize, Option<Box<dyn Aggregation>>) {
9999
let time = self.init_time.cumulative();
100-
let s_data = dest.and_then(|d| d.as_mut().downcast_mut::<data::Gauge<T>>());
100+
let s_data = dest.and_then(|d| d.as_mut().downcast_mut::<Gauge<T>>());
101101
let mut new_agg = if s_data.is_none() {
102102
Some(data::Gauge {
103103
data_points: vec![],

opentelemetry-sdk/src/metrics/internal/precomputed_sum.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use opentelemetry::KeyValue;
22

3-
use crate::metrics::data::{self, Aggregation, SumDataPoint};
3+
use crate::metrics::data::{self, Aggregation, Sum, SumDataPoint};
44
use crate::metrics::Temporality;
55

66
use super::aggregate::{AggregateTimeInitiator, AttributeSetFilter};
@@ -40,7 +40,7 @@ impl<T: Number> PrecomputedSum<T> {
4040
) -> (usize, Option<Box<dyn Aggregation>>) {
4141
let time = self.init_time.delta();
4242

43-
let s_data = dest.and_then(|d| d.as_mut().downcast_mut::<data::Sum<T>>());
43+
let s_data = dest.and_then(|d| d.as_mut().downcast_mut::<Sum<T>>());
4444
let mut new_agg = if s_data.is_none() {
4545
Some(data::Sum {
4646
data_points: vec![],
@@ -91,7 +91,7 @@ impl<T: Number> PrecomputedSum<T> {
9191
) -> (usize, Option<Box<dyn Aggregation>>) {
9292
let time = self.init_time.cumulative();
9393

94-
let s_data = dest.and_then(|d| d.as_mut().downcast_mut::<data::Sum<T>>());
94+
let s_data = dest.and_then(|d| d.as_mut().downcast_mut::<Sum<T>>());
9595
let mut new_agg = if s_data.is_none() {
9696
Some(data::Sum {
9797
data_points: vec![],

0 commit comments

Comments
 (0)