@@ -181,7 +181,6 @@ impl<T> MetricKindCollection<T> {
181181impl MetricKindCollection < Counter > {
182182 pub fn increment ( & mut self , name : & MetricName , labels : & LabelSet , time : DurationSinceUnixEpoch ) {
183183 if let Some ( metric) = self . metrics . get_mut ( name) {
184- // Direct hashmap lookup
185184 if let Some ( sample) = metric. samples . get_mut ( labels) {
186185 sample. value . increment ( 1 ) ;
187186 sample. update_at = time;
@@ -192,7 +191,7 @@ impl MetricKindCollection<Counter> {
192191 #[ must_use]
193192 pub fn get_value ( & self , name : & MetricName , labels : & LabelSet ) -> u64 {
194193 self . metrics
195- . get ( name) // Direct hashmap access
194+ . get ( name)
196195 . and_then ( |metric| metric. samples . get ( labels) )
197196 . map_or ( 0 , |sample| sample. value . value ( ) )
198197 }
@@ -212,7 +211,7 @@ impl MetricKindCollection<Gauge> {
212211 #[ must_use]
213212 pub fn get_value ( & self , name : & MetricName , labels : & LabelSet ) -> f64 {
214213 self . metrics
215- . get ( name) // Direct hashmap access
214+ . get ( name)
216215 . and_then ( |metric| metric. samples . get ( labels) )
217216 . map_or ( 0.0 , |sample| sample. value . value ( ) )
218217 }
@@ -224,22 +223,6 @@ pub struct Metric<T> {
224223 pub samples : SampleCollection < T > ,
225224}
226225
227- #[ derive( Serialize ) ]
228- #[ serde( tag = "kind" , rename_all = "lowercase" ) ]
229- #[ allow( dead_code) ]
230- enum SerializableMetric < ' a > {
231- Counter ( SerializableSpecificMetric < ' a , Counter > ) ,
232- Gauge ( SerializableSpecificMetric < ' a , Gauge > ) ,
233- }
234-
235- #[ derive( Serialize ) ]
236- #[ allow( dead_code) ]
237- struct SerializableSpecificMetric < ' a , T > {
238- name : & ' a MetricName ,
239- samples : & ' a SampleCollection < T > ,
240- }
241-
242- // Add to existing SampleCollection impl block
243226impl < T : Serialize > Serialize for SampleCollection < T > {
244227 fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
245228 where
0 commit comments