Skip to content

Commit 18fffd6

Browse files
ymgytdjc
authored andcommitted
chore: bump opentelemetry to 0.25
1 parent 8884fe6 commit 18fffd6

File tree

3 files changed

+102
-116
lines changed

3 files changed

+102
-116
lines changed

Cargo.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ metrics = ["opentelemetry/metrics","opentelemetry_sdk/metrics", "smallvec"]
2323
metrics_gauge_unstable = ["opentelemetry/otel_unstable"]
2424

2525
[dependencies]
26-
opentelemetry = { version = "0.24", default-features = false, features = ["trace"] }
27-
opentelemetry_sdk = { version = "0.24.1", default-features = false, features = ["trace"] }
26+
opentelemetry = { version = "0.25", default-features = false, features = ["trace"] }
27+
opentelemetry_sdk = { version = "0.25.0", default-features = false, features = ["trace"] }
2828
tracing = { version = "0.1.35", default-features = false, features = ["std"] }
2929
tracing-core = "0.1.28"
3030
tracing-subscriber = { version = "0.3.0", default-features = false, features = ["registry", "std"] }
@@ -41,11 +41,11 @@ smallvec = { version = "1.0", optional = true }
4141
[dev-dependencies]
4242
async-trait = "0.1.56"
4343
criterion = { version = "0.5.1", default-features = false, features = ["html_reports"] }
44-
opentelemetry = { version = "0.24", features = ["trace", "metrics"] }
45-
opentelemetry_sdk = { version = "0.24", default-features = false, features = ["trace", "rt-tokio"] }
46-
opentelemetry-stdout = { version = "0.5", features = ["trace", "metrics"] }
47-
opentelemetry-otlp = { version = "0.17", features = ["metrics"] }
48-
opentelemetry-semantic-conventions = "0.16"
44+
opentelemetry = { version = "0.25", features = ["trace", "metrics"] }
45+
opentelemetry_sdk = { version = "0.25", default-features = false, features = ["trace", "rt-tokio"] }
46+
opentelemetry-stdout = { version = "0.25", features = ["trace", "metrics"] }
47+
opentelemetry-otlp = { version = "0.25", features = ["metrics"] }
48+
opentelemetry-semantic-conventions = "0.25"
4949
futures-util = { version = "0.3.17", default-features = false }
5050
tokio = { version = "1", features = ["full"] }
5151
tokio-stream = "0.1"

examples/opentelemetry-otlp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use opentelemetry_sdk::{
99
Resource,
1010
};
1111
use opentelemetry_semantic_conventions::{
12-
resource::{DEPLOYMENT_ENVIRONMENT, SERVICE_NAME, SERVICE_VERSION},
12+
resource::{DEPLOYMENT_ENVIRONMENT_NAME, SERVICE_NAME, SERVICE_VERSION},
1313
SCHEMA_URL,
1414
};
1515
use tracing_core::Level;
@@ -22,7 +22,7 @@ fn resource() -> Resource {
2222
[
2323
KeyValue::new(SERVICE_NAME, env!("CARGO_PKG_NAME")),
2424
KeyValue::new(SERVICE_VERSION, env!("CARGO_PKG_VERSION")),
25-
KeyValue::new(DEPLOYMENT_ENVIRONMENT, "develop"),
25+
KeyValue::new(DEPLOYMENT_ENVIRONMENT_NAME, "develop"),
2626
],
2727
SCHEMA_URL,
2828
)

tests/metrics_publishing.rs

+93-107
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use opentelemetry_sdk::{
66
AggregationSelector, DefaultAggregationSelector, DefaultTemporalitySelector,
77
MetricReader, TemporalitySelector,
88
},
9-
AttributeSet, InstrumentKind, ManualReader, MeterProviderBuilder, SdkMeterProvider,
9+
InstrumentKind, ManualReader, MeterProviderBuilder, SdkMeterProvider,
1010
},
1111
Resource,
1212
};
@@ -195,16 +195,13 @@ async fn u64_counter_with_attributes_is_exported() {
195195
"hello_world".to_string(),
196196
InstrumentKind::Counter,
197197
1_u64,
198-
Some(AttributeSet::from(
199-
[
200-
KeyValue::new("u64_key_1", 1_i64),
201-
KeyValue::new("i64_key_1", 2_i64),
202-
KeyValue::new("f64_key_1", 3_f64),
203-
KeyValue::new("str_key_1", "foo"),
204-
KeyValue::new("bool_key_1", true),
205-
]
206-
.as_slice(),
207-
)),
198+
Some(vec![
199+
KeyValue::new("u64_key_1", 1_i64),
200+
KeyValue::new("i64_key_1", 2_i64),
201+
KeyValue::new("f64_key_1", 3_f64),
202+
KeyValue::new("str_key_1", "foo"),
203+
KeyValue::new("bool_key_1", true),
204+
]),
208205
);
209206

210207
tracing::subscriber::with_default(subscriber, || {
@@ -227,16 +224,13 @@ async fn f64_counter_with_attributes_is_exported() {
227224
"hello_world".to_string(),
228225
InstrumentKind::Counter,
229226
1_f64,
230-
Some(AttributeSet::from(
231-
[
232-
KeyValue::new("u64_key_1", 1_i64),
233-
KeyValue::new("i64_key_1", 2_i64),
234-
KeyValue::new("f64_key_1", 3_f64),
235-
KeyValue::new("str_key_1", "foo"),
236-
KeyValue::new("bool_key_1", true),
237-
]
238-
.as_slice(),
239-
)),
227+
Some(vec![
228+
KeyValue::new("u64_key_1", 1_i64),
229+
KeyValue::new("i64_key_1", 2_i64),
230+
KeyValue::new("f64_key_1", 3_f64),
231+
KeyValue::new("str_key_1", "foo"),
232+
KeyValue::new("bool_key_1", true),
233+
]),
240234
);
241235

242236
tracing::subscriber::with_default(subscriber, || {
@@ -259,16 +253,13 @@ async fn i64_up_down_counter_with_attributes_is_exported() {
259253
"hello_world".to_string(),
260254
InstrumentKind::UpDownCounter,
261255
-1_i64,
262-
Some(AttributeSet::from(
263-
[
264-
KeyValue::new("u64_key_1", 1_i64),
265-
KeyValue::new("i64_key_1", 2_i64),
266-
KeyValue::new("f64_key_1", 3_f64),
267-
KeyValue::new("str_key_1", "foo"),
268-
KeyValue::new("bool_key_1", true),
269-
]
270-
.as_slice(),
271-
)),
256+
Some(vec![
257+
KeyValue::new("u64_key_1", 1_i64),
258+
KeyValue::new("i64_key_1", 2_i64),
259+
KeyValue::new("f64_key_1", 3_f64),
260+
KeyValue::new("str_key_1", "foo"),
261+
KeyValue::new("bool_key_1", true),
262+
]),
272263
);
273264

274265
tracing::subscriber::with_default(subscriber, || {
@@ -291,16 +282,13 @@ async fn f64_up_down_counter_with_attributes_is_exported() {
291282
"hello_world".to_string(),
292283
InstrumentKind::UpDownCounter,
293284
-1_f64,
294-
Some(AttributeSet::from(
295-
[
296-
KeyValue::new("u64_key_1", 1_i64),
297-
KeyValue::new("i64_key_1", 2_i64),
298-
KeyValue::new("f64_key_1", 3_f64),
299-
KeyValue::new("str_key_1", "foo"),
300-
KeyValue::new("bool_key_1", true),
301-
]
302-
.as_slice(),
303-
)),
285+
Some(vec![
286+
KeyValue::new("u64_key_1", 1_i64),
287+
KeyValue::new("i64_key_1", 2_i64),
288+
KeyValue::new("f64_key_1", 3_f64),
289+
KeyValue::new("str_key_1", "foo"),
290+
KeyValue::new("bool_key_1", true),
291+
]),
304292
);
305293

306294
tracing::subscriber::with_default(subscriber, || {
@@ -324,16 +312,13 @@ async fn f64_gauge_with_attributes_is_exported() {
324312
"hello_world".to_string(),
325313
InstrumentKind::Gauge,
326314
1_f64,
327-
Some(AttributeSet::from(
328-
[
329-
KeyValue::new("u64_key_1", 1_i64),
330-
KeyValue::new("i64_key_1", 2_i64),
331-
KeyValue::new("f64_key_1", 3_f64),
332-
KeyValue::new("str_key_1", "foo"),
333-
KeyValue::new("bool_key_1", true),
334-
]
335-
.as_slice(),
336-
)),
315+
Some(vec![
316+
KeyValue::new("u64_key_1", 1_i64),
317+
KeyValue::new("i64_key_1", 2_i64),
318+
KeyValue::new("f64_key_1", 3_f64),
319+
KeyValue::new("str_key_1", "foo"),
320+
KeyValue::new("bool_key_1", true),
321+
]),
337322
);
338323

339324
tracing::subscriber::with_default(subscriber, || {
@@ -357,16 +342,13 @@ async fn u64_gauge_with_attributes_is_exported() {
357342
"hello_world".to_string(),
358343
InstrumentKind::Gauge,
359344
1_u64,
360-
Some(AttributeSet::from(
361-
[
362-
KeyValue::new("u64_key_1", 1_i64),
363-
KeyValue::new("i64_key_1", 2_i64),
364-
KeyValue::new("f64_key_1", 3_f64),
365-
KeyValue::new("str_key_1", "foo"),
366-
KeyValue::new("bool_key_1", true),
367-
]
368-
.as_slice(),
369-
)),
345+
Some(vec![
346+
KeyValue::new("u64_key_1", 1_i64),
347+
KeyValue::new("i64_key_1", 2_i64),
348+
KeyValue::new("f64_key_1", 3_f64),
349+
KeyValue::new("str_key_1", "foo"),
350+
KeyValue::new("bool_key_1", true),
351+
]),
370352
);
371353

372354
tracing::subscriber::with_default(subscriber, || {
@@ -390,16 +372,13 @@ async fn i64_gauge_with_attributes_is_exported() {
390372
"hello_world".to_string(),
391373
InstrumentKind::Gauge,
392374
1_i64,
393-
Some(AttributeSet::from(
394-
[
395-
KeyValue::new("u64_key_1", 1_i64),
396-
KeyValue::new("i64_key_1", 2_i64),
397-
KeyValue::new("f64_key_1", 3_f64),
398-
KeyValue::new("str_key_1", "foo"),
399-
KeyValue::new("bool_key_1", true),
400-
]
401-
.as_slice(),
402-
)),
375+
Some(vec![
376+
KeyValue::new("u64_key_1", 1_i64),
377+
KeyValue::new("i64_key_1", 2_i64),
378+
KeyValue::new("f64_key_1", 3_f64),
379+
KeyValue::new("str_key_1", "foo"),
380+
KeyValue::new("bool_key_1", true),
381+
]),
403382
);
404383

405384
tracing::subscriber::with_default(subscriber, || {
@@ -422,16 +401,13 @@ async fn u64_histogram_with_attributes_is_exported() {
422401
"hello_world".to_string(),
423402
InstrumentKind::Histogram,
424403
1_u64,
425-
Some(AttributeSet::from(
426-
[
427-
KeyValue::new("u64_key_1", 1_i64),
428-
KeyValue::new("i64_key_1", 2_i64),
429-
KeyValue::new("f64_key_1", 3_f64),
430-
KeyValue::new("str_key_1", "foo"),
431-
KeyValue::new("bool_key_1", true),
432-
]
433-
.as_slice(),
434-
)),
404+
Some(vec![
405+
KeyValue::new("u64_key_1", 1_i64),
406+
KeyValue::new("i64_key_1", 2_i64),
407+
KeyValue::new("f64_key_1", 3_f64),
408+
KeyValue::new("str_key_1", "foo"),
409+
KeyValue::new("bool_key_1", true),
410+
]),
435411
);
436412

437413
tracing::subscriber::with_default(subscriber, || {
@@ -454,16 +430,13 @@ async fn f64_histogram_with_attributes_is_exported() {
454430
"hello_world".to_string(),
455431
InstrumentKind::Histogram,
456432
1_f64,
457-
Some(AttributeSet::from(
458-
[
459-
KeyValue::new("u64_key_1", 1_i64),
460-
KeyValue::new("i64_key_1", 2_i64),
461-
KeyValue::new("f64_key_1", 3_f64),
462-
KeyValue::new("str_key_1", "foo"),
463-
KeyValue::new("bool_key_1", true),
464-
]
465-
.as_slice(),
466-
)),
433+
Some(vec![
434+
KeyValue::new("u64_key_1", 1_i64),
435+
KeyValue::new("i64_key_1", 2_i64),
436+
KeyValue::new("f64_key_1", 3_f64),
437+
KeyValue::new("str_key_1", "foo"),
438+
KeyValue::new("bool_key_1", true),
439+
]),
467440
);
468441

469442
tracing::subscriber::with_default(subscriber, || {
@@ -486,9 +459,7 @@ async fn display_attribute_is_exported() {
486459
"hello_world".to_string(),
487460
InstrumentKind::Counter,
488461
1_u64,
489-
Some(AttributeSet::from(
490-
[KeyValue::new("display_key_1", "display: foo")].as_slice(),
491-
)),
462+
Some(vec![KeyValue::new("display_key_1", "display: foo")]),
492463
);
493464

494465
struct DisplayAttribute(String);
@@ -517,9 +488,7 @@ async fn debug_attribute_is_exported() {
517488
"hello_world".to_string(),
518489
InstrumentKind::Counter,
519490
1_u64,
520-
Some(AttributeSet::from(
521-
[KeyValue::new("debug_key_1", "debug: foo")].as_slice(),
522-
)),
491+
Some(vec![KeyValue::new("debug_key_1", "debug: foo")]),
523492
);
524493

525494
struct DebugAttribute(String);
@@ -546,7 +515,7 @@ fn init_subscriber<T>(
546515
expected_metric_name: String,
547516
expected_instrument_kind: InstrumentKind,
548517
expected_value: T,
549-
expected_attributes: Option<AttributeSet>,
518+
expected_attributes: Option<Vec<KeyValue>>,
550519
) -> (impl Subscriber + 'static, TestExporter<T>) {
551520
let reader = ManualReader::builder()
552521
.with_aggregation_selector(DefaultAggregationSelector::new())
@@ -563,12 +532,7 @@ fn init_subscriber<T>(
563532
expected_metric_name,
564533
expected_instrument_kind,
565534
expected_value,
566-
expected_attributes: expected_attributes.map(|attrs| {
567-
attrs
568-
.iter()
569-
.map(|(k, v)| KeyValue::new(k.clone(), v.clone()))
570-
.collect()
571-
}),
535+
expected_attributes,
572536
reader,
573537
_meter_provider: provider.clone(),
574538
};
@@ -659,7 +623,10 @@ where
659623

660624
if let Some(expected_attributes) = self.expected_attributes.as_ref() {
661625
sum.data_points.iter().for_each(|data_point| {
662-
assert_eq!(expected_attributes, &data_point.attributes)
626+
assert!(compare_attributes(
627+
expected_attributes,
628+
&data_point.attributes,
629+
))
663630
});
664631
}
665632
}
@@ -677,7 +644,10 @@ where
677644

678645
if let Some(expected_attributes) = self.expected_attributes.as_ref() {
679646
gauge.data_points.iter().for_each(|data_point| {
680-
assert_eq!(expected_attributes, &data_point.attributes)
647+
assert!(compare_attributes(
648+
expected_attributes,
649+
&data_point.attributes,
650+
))
681651
});
682652
}
683653
}
@@ -689,7 +659,10 @@ where
689659
assert_eq!(histogram_data.sum, self.expected_value);
690660

691661
if let Some(expected_attributes) = self.expected_attributes.as_ref() {
692-
assert_eq!(expected_attributes, &histogram_data.attributes);
662+
assert!(compare_attributes(
663+
expected_attributes,
664+
&histogram_data.attributes
665+
))
693666
}
694667
}
695668
unexpected => {
@@ -702,3 +675,16 @@ where
702675
Ok(())
703676
}
704677
}
678+
679+
// After sorting the KeyValue vec, compare them.
680+
// Return true if they are equal.
681+
#[allow(clippy::ptr_arg)]
682+
fn compare_attributes(expected: &Vec<KeyValue>, actual: &Vec<KeyValue>) -> bool {
683+
let mut expected = expected.clone();
684+
let mut actual = actual.clone();
685+
686+
expected.sort();
687+
actual.sort();
688+
689+
expected == actual
690+
}

0 commit comments

Comments
 (0)