@@ -22,6 +22,10 @@ struct Args {
2222 #[ clap( short, long) ]
2323 metric : Option < String > ,
2424
25+ /// dump a metric's values. Requires --metric.
26+ #[ clap( short, long) ]
27+ dump_values : bool ,
28+
2529 /// Path to line-delimited capture file
2630 capture_path : String ,
2731}
@@ -88,7 +92,7 @@ async fn main() -> Result<(), Error> {
8892 return Ok ( ( ) ) ;
8993 }
9094
91- if let Some ( metric) = args. metric {
95+ if let Some ( metric) = & args. metric {
9296 // key is hash of the metric name and all the sorted, concatenated labels
9397 // value is a tuple of
9498 // - hashset of "key:value" strings (aka, concatenated labels)
@@ -100,7 +104,7 @@ async fn main() -> Result<(), Error> {
100104 // Use a BTreeSet to ensure that the tags are sorted
101105 lines
102106 . iter ( )
103- . filter ( |line| line. metric_name == metric)
107+ . filter ( |line| & line. metric_name == metric)
104108 . for_each ( |line| {
105109 let mut sorted_labels: BTreeSet < String > = BTreeSet :: new ( ) ;
106110 for ( key, value) in line. labels . iter ( ) {
@@ -133,6 +137,20 @@ async fn main() -> Result<(), Error> {
133137 }
134138 }
135139
140+ if args. dump_values {
141+ if let Some ( metric) = & args. metric {
142+ lines
143+ . iter ( )
144+ . filter ( |line| & line. metric_name == metric)
145+ . for_each ( |line| {
146+ println ! ( "{}: {}" , line. fetch_index, line. value) ;
147+ } ) ;
148+ } else {
149+ error ! ( "--dump-values requires --metric" ) ;
150+ return Err ( Error :: InvalidArgs ) ;
151+ }
152+ }
153+
136154 info ! ( "Bye. :)" ) ;
137155 Ok ( ( ) )
138156}
0 commit comments