@@ -15,6 +15,7 @@ use opentelemetry_sdk::Resource;
1515use opentelemetry_semantic_conventions:: resource:: { SERVICE_NAME , TELEMETRY_SDK_VERSION } ;
1616use prometheus:: { Encoder , TextEncoder } ;
1717
18+ #[ ignore = "https://github.com/open-telemetry/opentelemetry-rust/pull/2224" ]
1819#[ test]
1920fn 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