Skip to content

Commit f4ec413

Browse files
authored
Merge branch 'main' into fix/random_tests_promethus
2 parents 9211603 + ea4b5e4 commit f4ec413

File tree

6 files changed

+288
-90
lines changed

6 files changed

+288
-90
lines changed

opentelemetry-prometheus/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
## vNext
44

55
- Bump MSRV to 1.70 [#2179](https://github.com/open-telemetry/opentelemetry-rust/pull/2179)
6+
- Update `opentelemetry` dependency version to 0.26
7+
- Update `opentelemetry_sdk` dependency version to 0.26
8+
- Update `opentelemetry-semantic-conventions` dependency version to 0.26
9+
610

711
## v0.17.0
812

opentelemetry-prometheus/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ rustdoc-args = ["--cfg", "docsrs"]
2121

2222
[dependencies]
2323
once_cell = { workspace = true }
24-
opentelemetry = { version = "0.24", default-features = false, features = ["metrics"] }
25-
opentelemetry_sdk = { version = "0.24", default-features = false, features = ["metrics"] }
24+
opentelemetry = { version = "0.26", default-features = false, features = ["metrics"] }
25+
opentelemetry_sdk = { version = "0.26", default-features = false, features = ["metrics"] }
2626
prometheus = "0.13"
2727
protobuf = "2.14"
2828

2929
[dev-dependencies]
30-
opentelemetry-semantic-conventions = { version = "0.16" }
30+
opentelemetry-semantic-conventions = { version = "0.26" }
3131
http-body-util = { workspace = true }
3232
hyper = { workspace = true, features = ["full"] }
3333
hyper-util = { workspace = true, features = ["full"] }

opentelemetry-prometheus/src/config.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
use core::fmt;
22
use once_cell::sync::OnceCell;
33
use opentelemetry::metrics::{MetricsError, Result};
4-
use opentelemetry_sdk::metrics::{
5-
reader::{AggregationSelector, MetricProducer},
6-
ManualReaderBuilder,
7-
};
4+
use opentelemetry_sdk::metrics::ManualReaderBuilder;
85
use std::sync::{Arc, Mutex};
96

107
use crate::{Collector, PrometheusExporter, ResourceSelector};
@@ -105,16 +102,6 @@ impl ExporterBuilder {
105102
self
106103
}
107104

108-
/// Configure the [AggregationSelector] the exporter will use.
109-
///
110-
/// If no selector is provided, the [DefaultAggregationSelector] is used.
111-
///
112-
/// [DefaultAggregationSelector]: opentelemetry_sdk::metrics::reader::DefaultAggregationSelector
113-
pub fn with_aggregation_selector(mut self, agg: impl AggregationSelector + 'static) -> Self {
114-
self.reader = self.reader.with_aggregation_selector(agg);
115-
self
116-
}
117-
118105
/// Configures whether to export resource as attributes with every metric.
119106
///
120107
/// Note that this is orthogonal to the `target_info` metric, which can be disabled using `without_target_info`.
@@ -128,15 +115,6 @@ impl ExporterBuilder {
128115
self
129116
}
130117

131-
/// Registers an external [MetricProducer] with this reader.
132-
///
133-
/// The producer is used as a source of aggregated metric data which is
134-
/// incorporated into metrics collected from the SDK.
135-
pub fn with_producer(mut self, producer: impl MetricProducer + 'static) -> Self {
136-
self.reader = self.reader.with_producer(producer);
137-
self
138-
}
139-
140118
/// Creates a new [PrometheusExporter] from this configuration.
141119
pub fn build(self) -> Result<PrometheusExporter> {
142120
let reader = Arc::new(self.reader.build());

opentelemetry-prometheus/src/lib.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ use opentelemetry::{
105105
use opentelemetry_sdk::{
106106
metrics::{
107107
data::{self, ResourceMetrics, Temporality},
108-
reader::{AggregationSelector, MetricReader, TemporalitySelector},
109-
Aggregation, InstrumentKind, ManualReader, Pipeline,
108+
reader::{MetricReader, TemporalitySelector},
109+
InstrumentKind, ManualReader, Pipeline,
110110
},
111111
Resource, Scope,
112112
};
@@ -160,12 +160,6 @@ impl TemporalitySelector for PrometheusExporter {
160160
}
161161
}
162162

163-
impl AggregationSelector for PrometheusExporter {
164-
fn aggregation(&self, kind: InstrumentKind) -> Aggregation {
165-
self.reader.aggregation(kind)
166-
}
167-
}
168-
169163
impl MetricReader for PrometheusExporter {
170164
fn register_pipeline(&self, pipeline: Weak<Pipeline>) {
171165
self.reader.register_pipeline(pipeline)

opentelemetry-prometheus/tests/integration_test.rs

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use opentelemetry_sdk::Resource;
1515
use opentelemetry_semantic_conventions::resource::{SERVICE_NAME, TELEMETRY_SDK_VERSION};
1616
use prometheus::{Encoder, TextEncoder};
1717

18+
#[ignore = "https://github.com/open-telemetry/opentelemetry-rust/pull/2224"]
1819
#[test]
1920
fn prometheus_exporter_integration() {
2021
struct TestCase {
@@ -46,10 +47,10 @@ fn prometheus_exporter_integration() {
4647
expected_file: "counter.txt",
4748
record_metrics: Box::new(|meter| {
4849
let attrs = vec![
49-
Key::new("A").string("B"),
50-
Key::new("C").string("D"),
51-
Key::new("E").bool(true),
52-
Key::new("F").i64(42),
50+
KeyValue::new("A", "B"),
51+
KeyValue::new("C", "D"),
52+
KeyValue::new("E", true),
53+
KeyValue::new("F", 42),
5354
];
5455
let counter = meter
5556
.f64_counter("foo")
@@ -60,10 +61,10 @@ fn prometheus_exporter_integration() {
6061
counter.add(10.3, &attrs);
6162
counter.add(9.0, &attrs);
6263
let attrs2 = vec![
63-
Key::new("A").string("D"),
64-
Key::new("C").string("B"),
65-
Key::new("E").bool(true),
66-
Key::new("F").i64(42),
64+
KeyValue::new("A", "D"),
65+
KeyValue::new("C", "B"),
66+
KeyValue::new("E", true),
67+
KeyValue::new("F", 42),
6768
];
6869
counter.add(5.0, &attrs2);
6970
}),
@@ -75,10 +76,10 @@ fn prometheus_exporter_integration() {
7576
builder: ExporterBuilder::default().without_counter_suffixes(),
7677
record_metrics: Box::new(|meter| {
7778
let attrs = vec![
78-
Key::new("A").string("B"),
79-
Key::new("C").string("D"),
80-
Key::new("E").bool(true),
81-
Key::new("F").i64(42),
79+
KeyValue::new("A", "B"),
80+
KeyValue::new("C", "D"),
81+
KeyValue::new("E", true),
82+
KeyValue::new("F", 42),
8283
];
8384
let counter = meter
8485
.f64_counter("foo")
@@ -89,10 +90,10 @@ fn prometheus_exporter_integration() {
8990
counter.add(10.3, &attrs);
9091
counter.add(9.0, &attrs);
9192
let attrs2 = vec![
92-
Key::new("A").string("D"),
93-
Key::new("C").string("B"),
94-
Key::new("E").bool(true),
95-
Key::new("F").i64(42),
93+
KeyValue::new("A", "D"),
94+
KeyValue::new("C", "B"),
95+
KeyValue::new("E", true),
96+
KeyValue::new("F", 42),
9697
];
9798
counter.add(5.0, &attrs2);
9899
}),
@@ -102,7 +103,7 @@ fn prometheus_exporter_integration() {
102103
name: "gauge",
103104
expected_file: "gauge.txt",
104105
record_metrics: Box::new(|meter| {
105-
let attrs = vec![Key::new("A").string("B"), Key::new("C").string("D")];
106+
let attrs = vec![KeyValue::new("A", "B"), KeyValue::new("C", "D")];
106107
let gauge = meter
107108
.f64_up_down_counter("bar")
108109
.with_description("a fun little gauge")
@@ -117,7 +118,7 @@ fn prometheus_exporter_integration() {
117118
name: "histogram",
118119
expected_file: "histogram.txt",
119120
record_metrics: Box::new(|meter| {
120-
let attrs = vec![Key::new("A").string("B"), Key::new("C").string("D")];
121+
let attrs = vec![KeyValue::new("A", "B"), KeyValue::new("C", "D")];
121122
let histogram = meter
122123
.f64_histogram("histogram_baz")
123124
.with_description("a very nice histogram")
@@ -137,11 +138,11 @@ fn prometheus_exporter_integration() {
137138
record_metrics: Box::new(|meter| {
138139
let attrs = vec![
139140
// exact match, value should be overwritten
140-
Key::new("A.B").string("X"),
141-
Key::new("A.B").string("Q"),
141+
KeyValue::new("A.B", "X"),
142+
KeyValue::new("A.B", "Q"),
142143
// unintended match due to sanitization, values should be concatenated
143-
Key::new("C.D").string("Y"),
144-
Key::new("C/D").string("Z"),
144+
KeyValue::new("C.D", "Y"),
145+
KeyValue::new("C/D", "Z"),
145146
];
146147
let counter = meter
147148
.f64_counter("foo")
@@ -159,7 +160,7 @@ fn prometheus_exporter_integration() {
159160
name: "invalid instruments are renamed",
160161
expected_file: "sanitized_names.txt",
161162
record_metrics: Box::new(|meter| {
162-
let attrs = vec![Key::new("A").string("B"), Key::new("C").string("D")];
163+
let attrs = vec![KeyValue::new("A", "B"), KeyValue::new("C", "D")];
163164
// Valid.
164165
let mut gauge = meter
165166
.f64_up_down_counter("bar")
@@ -195,10 +196,10 @@ fn prometheus_exporter_integration() {
195196
expected_file: "empty_resource.txt",
196197
record_metrics: Box::new(|meter| {
197198
let attrs = vec![
198-
Key::new("A").string("B"),
199-
Key::new("C").string("D"),
200-
Key::new("E").bool(true),
201-
Key::new("F").i64(42),
199+
KeyValue::new("A", "B"),
200+
KeyValue::new("C", "D"),
201+
KeyValue::new("E", true),
202+
KeyValue::new("F", 42),
202203
];
203204
let counter = meter
204205
.f64_counter("foo")
@@ -212,14 +213,14 @@ fn prometheus_exporter_integration() {
212213
},
213214
TestCase {
214215
name: "custom resource",
215-
custom_resource_attrs: vec![Key::new("A").string("B"), Key::new("C").string("D")],
216+
custom_resource_attrs: vec![KeyValue::new("A", "B"), KeyValue::new("C", "D")],
216217
expected_file: "custom_resource.txt",
217218
record_metrics: Box::new(|meter| {
218219
let attrs = vec![
219-
Key::new("A").string("B"),
220-
Key::new("C").string("D"),
221-
Key::new("E").bool(true),
222-
Key::new("F").i64(42),
220+
KeyValue::new("A", "B"),
221+
KeyValue::new("C", "D"),
222+
KeyValue::new("E", true),
223+
KeyValue::new("F", 42),
223224
];
224225
let counter = meter
225226
.f64_counter("foo")
@@ -237,10 +238,10 @@ fn prometheus_exporter_integration() {
237238
expected_file: "without_target_info.txt",
238239
record_metrics: Box::new(|meter| {
239240
let attrs = vec![
240-
Key::new("A").string("B"),
241-
Key::new("C").string("D"),
242-
Key::new("E").bool(true),
243-
Key::new("F").i64(42),
241+
KeyValue::new("A", "B"),
242+
KeyValue::new("C", "D"),
243+
KeyValue::new("E", true),
244+
KeyValue::new("F", 42),
244245
];
245246
let counter = meter
246247
.f64_counter("foo")
@@ -257,7 +258,7 @@ fn prometheus_exporter_integration() {
257258
builder: ExporterBuilder::default().without_scope_info(),
258259
expected_file: "without_scope_info.txt",
259260
record_metrics: Box::new(|meter| {
260-
let attrs = vec![Key::new("A").string("B"), Key::new("C").string("D")];
261+
let attrs = vec![KeyValue::new("A", "B"), KeyValue::new("C", "D")];
261262
let gauge = meter
262263
.i64_up_down_counter("bar")
263264
.with_description("a fun little gauge")
@@ -275,7 +276,7 @@ fn prometheus_exporter_integration() {
275276
.without_target_info(),
276277
expected_file: "without_scope_and_target_info.txt",
277278
record_metrics: Box::new(|meter| {
278-
let attrs = vec![Key::new("A").string("B"), Key::new("C").string("D")];
279+
let attrs = vec![KeyValue::new("A", "B"), KeyValue::new("C", "D")];
279280
let counter = meter
280281
.u64_counter("bar")
281282
.with_description("a fun little counter")
@@ -292,10 +293,10 @@ fn prometheus_exporter_integration() {
292293
expected_file: "with_namespace.txt",
293294
record_metrics: Box::new(|meter| {
294295
let attrs = vec![
295-
Key::new("A").string("B"),
296-
Key::new("C").string("D"),
297-
Key::new("E").bool(true),
298-
Key::new("F").i64(42),
296+
KeyValue::new("A", "B"),
297+
KeyValue::new("C", "D"),
298+
KeyValue::new("E", true),
299+
KeyValue::new("F", 42),
299300
];
300301
let counter = meter
301302
.f64_counter("foo")
@@ -313,7 +314,7 @@ fn prometheus_exporter_integration() {
313314
builder: ExporterBuilder::default().with_resource_selector(ResourceSelector::All),
314315
expected_file: "resource_in_every_metrics.txt",
315316
record_metrics: Box::new(|meter| {
316-
let attrs = vec![Key::new("A").string("B"), Key::new("C").string("D")];
317+
let attrs = vec![KeyValue::new("A", "B"), KeyValue::new("C", "D")];
317318
let gauge = meter
318319
.i64_up_down_counter("bar")
319320
.with_description("a fun little gauge")
@@ -330,7 +331,7 @@ fn prometheus_exporter_integration() {
330331
.with_resource_selector(HashSet::from([Key::new("service.name")])),
331332
expected_file: "select_resource_in_every_metrics.txt",
332333
record_metrics: Box::new(|meter| {
333-
let attrs = vec![Key::new("A").string("B"), Key::new("C").string("D")];
334+
let attrs = vec![KeyValue::new("A", "B"), KeyValue::new("C", "D")];
334335
let gauge = meter
335336
.i64_up_down_counter("bar")
336337
.with_description("a fun little gauge")

0 commit comments

Comments
 (0)