@@ -6,7 +6,7 @@ use std::time::Instant;
66use cadence:: {
77 BufferedUdpMetricSink , Counted , Metric , NopMetricSink , QueuingMetricSink , StatsdClient , Timed ,
88} ;
9- use slog:: { Key , Record , KV } ;
9+ use slog:: { KV , Key , Record } ;
1010
1111pub use cadence:: MetricError ;
1212
@@ -27,26 +27,26 @@ pub struct Metrics {
2727impl Drop for Metrics {
2828 fn drop ( & mut self ) {
2929 let tags = self . tags . clone ( ) ;
30- if let Some ( client) = self . client . as_ref ( ) {
31- if let Some ( timer) = self . timer . as_ref ( ) {
32- let lapse = ( Instant :: now ( ) - timer. start ) . as_millis ( ) as u64 ;
33- trace ! ( "⌚ Ending timer at nanos: {:?} : {:?}" , & timer. label, lapse; & MetricTags ( tags) ) ;
34- let mut tagged = client. time_with_tags ( & timer. label , lapse) ;
35- // Include any "hard coded" tags.
36- // tagged = tagged.with_tag("version", env!("CARGO_PKG_VERSION"));
37- let tags = timer. tags . clone ( ) ;
38- let keys = tags. keys ( ) ;
39- for tag in keys {
40- tagged = tagged. with_tag ( tag, tags. get ( tag) . unwrap ( ) )
30+ if let Some ( client) = self . client . as_ref ( )
31+ && let Some ( timer) = self . timer . as_ref ( )
32+ {
33+ let lapse = ( Instant :: now ( ) - timer. start ) . as_millis ( ) as u64 ;
34+ trace ! ( "⌚ Ending timer at nanos: {:?} : {:?}" , & timer. label, lapse; & MetricTags ( tags) ) ;
35+ let mut tagged = client. time_with_tags ( & timer. label , lapse) ;
36+ // Include any "hard coded" tags.
37+ // tagged = tagged.with_tag("version", env!("CARGO_PKG_VERSION"));
38+ let tags = timer. tags . clone ( ) ;
39+ let keys = tags. keys ( ) ;
40+ for tag in keys {
41+ tagged = tagged. with_tag ( tag, tags. get ( tag) . unwrap ( ) )
42+ }
43+ match tagged. try_send ( ) {
44+ Err ( e) => {
45+ // eat the metric, but log the error
46+ warn ! ( "⚠️ Metric {} error: {:?} " , & timer. label, e) ;
4147 }
42- match tagged. try_send ( ) {
43- Err ( e) => {
44- // eat the metric, but log the error
45- warn ! ( "⚠️ Metric {} error: {:?} " , & timer. label, e) ;
46- }
47- Ok ( v) => {
48- trace ! ( "⌚ {:?}" , v. as_metric_str( ) ) ;
49- }
48+ Ok ( v) => {
49+ trace ! ( "⌚ {:?}" , v. as_metric_str( ) ) ;
5050 }
5151 }
5252 }
0 commit comments