File tree 3 files changed +7
-6
lines changed 3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -85,13 +85,13 @@ impl Registry {
85
85
///
86
86
/// Note that this does not add the EOF marker to the output. Use [`encode_openmetrics_eof`]
87
87
/// to do that.
88
- pub fn encode_openmetrics ( & self , writer : & mut impl Write ) -> fmt:: Result {
88
+ pub fn encode_openmetrics_to_writer ( & self , writer : & mut impl Write ) -> fmt:: Result {
89
89
for group in & self . metrics {
90
90
group. encode_openmetrics ( writer, self . prefix . as_deref ( ) , & self . labels ) ?;
91
91
}
92
92
93
93
for sub in self . sub_registries . iter ( ) {
94
- sub. encode_openmetrics ( writer) ?;
94
+ sub. encode_openmetrics_to_writer ( writer) ?;
95
95
}
96
96
Ok ( ( ) )
97
97
}
@@ -119,7 +119,7 @@ pub trait MetricsSource: Send + 'static {
119
119
120
120
impl MetricsSource for Registry {
121
121
fn encode_openmetrics ( & self , writer : & mut impl std:: fmt:: Write ) -> Result < ( ) , Error > {
122
- self . encode_openmetrics ( writer) ?;
122
+ self . encode_openmetrics_to_writer ( writer) ?;
123
123
write_eof ( writer) ?;
124
124
Ok ( ( ) )
125
125
}
Original file line number Diff line number Diff line change 2
2
3
3
use std:: {
4
4
net:: SocketAddr ,
5
+ ops:: Deref ,
5
6
sync:: { Arc , RwLock } ,
6
7
time:: { Duration , Instant } ,
7
8
} ;
@@ -23,13 +24,13 @@ pub type RwLockRegistry = Arc<RwLock<Registry>>;
23
24
impl MetricsSource for RwLockRegistry {
24
25
fn encode_openmetrics ( & self , writer : & mut impl std:: fmt:: Write ) -> Result < ( ) , Error > {
25
26
let inner = self . read ( ) . expect ( "poisoned" ) ;
26
- < Registry as MetricsSource > :: encode_openmetrics ( & inner , writer)
27
+ inner . encode_openmetrics ( writer)
27
28
}
28
29
}
29
30
30
31
impl MetricsSource for Arc < Registry > {
31
32
fn encode_openmetrics ( & self , writer : & mut impl std:: fmt:: Write ) -> Result < ( ) , Error > {
32
- < Registry as MetricsSource > :: encode_openmetrics ( self , writer)
33
+ Arc :: deref ( self ) . encode_openmetrics ( writer)
33
34
}
34
35
}
35
36
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ pub struct GlobalRegistry;
49
49
impl MetricsSource for GlobalRegistry {
50
50
fn encode_openmetrics ( & self , writer : & mut impl std:: fmt:: Write ) -> Result < ( ) , Error > {
51
51
let core = crate :: static_core:: Core :: get ( ) . ok_or ( NoMetricsSnafu . build ( ) ) ?;
52
- < Registry as MetricsSource > :: encode_openmetrics ( & core. registry , writer)
52
+ core. registry . encode_openmetrics ( writer)
53
53
}
54
54
}
55
55
You can’t perform that action at this time.
0 commit comments