File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ enum Commands {
1717 /// Number of samples to run for. Set to 0 to run indefinitely
1818 #[ arg( short, long, default_value_t = 0 ) ]
1919 samples : u32 ,
20+
21+ /// Include SoC information in the output
22+ #[ arg( long, default_value_t = false ) ]
23+ soc_info : bool ,
2024 } ,
2125
2226 /// Print debug information
@@ -40,18 +44,23 @@ fn main() -> Result<(), Box<dyn Error>> {
4044 let args = Cli :: parse ( ) ;
4145
4246 match & args. command {
43- Some ( Commands :: Pipe { samples } ) => {
47+ Some ( Commands :: Pipe { samples, soc_info } ) => {
4448 let mut sampler = Sampler :: new ( ) ?;
4549 let mut counter = 0u32 ;
4650
47- // Clone soc_info to avoid borrow conflicts
48- let soc_info = sampler. get_soc_info ( ) . clone ( ) ;
51+ let soc_info_val = if * soc_info {
52+ Some ( sampler. get_soc_info ( ) . clone ( ) )
53+ } else {
54+ None
55+ } ;
4956
5057 loop {
5158 let doc = sampler. get_metrics ( args. interval . max ( 100 ) ) ?;
5259
5360 let mut doc = serde_json:: to_value ( & doc) ?;
54- doc[ "soc" ] = serde_json:: to_value ( & soc_info) ?;
61+ if let Some ( ref soc) = soc_info_val {
62+ doc[ "soc" ] = serde_json:: to_value ( soc) ?;
63+ }
5564 doc[ "timestamp" ] = serde_json:: to_value ( chrono:: Utc :: now ( ) . to_rfc3339 ( ) ) ?;
5665 let doc = serde_json:: to_string ( & doc) ?;
5766
You can’t perform that action at this time.
0 commit comments