File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -418,7 +418,17 @@ where
418418 return self ;
419419 } ;
420420
421- tokio:: process:: Command :: new ( binary_path:: current_exe_for_but_exec ( ) ?)
421+ // We can fail both in resolving the path to the but binary, and in invoking it. As metrics
422+ // emissions shouldn't impact user experience, we swallow these errors.
423+ let but_path = match binary_path:: current_exe_for_but_exec ( ) {
424+ Err ( err) => {
425+ tracing:: warn!( ?err, "Failed to resolve binary path to `but`" ) ;
426+ return self ;
427+ }
428+ Ok ( path) => path,
429+ } ;
430+
431+ let _ = tokio:: process:: Command :: new ( but_path)
422432 . arg ( "metrics" )
423433 . arg ( "--command-name" )
424434 . arg ( v. get_name ( ) )
@@ -428,7 +438,9 @@ where
428438 . stdout ( std:: process:: Stdio :: null ( ) )
429439 . group ( )
430440 . kill_on_drop ( false )
431- . spawn ( ) ?;
441+ . spawn ( )
442+ . map_err ( |err| tracing:: warn!( ?err, "Failed to emit metrics" ) ) ;
443+
432444 self
433445 }
434446}
Original file line number Diff line number Diff line change @@ -43,8 +43,13 @@ impl ResultErrorExt for anyhow::Result<()> {
4343 }
4444}
4545
46- /// Utilities attached to `anyhow::Result<T>`.
46+ /// Metrics utilities for results
4747pub trait ResultMetricsExt < T , E > {
48+ /// Emit metrics for the [`Result`].
49+ ///
50+ /// The result must simply be propagated through this method, regardless of if emitting metrics
51+ /// is successful or not. We do not want a failure to emit metrics to impact the user
52+ /// experience.
4853 fn emit_metrics ( self , ctx : Option < OneshotMetricsContext > ) -> Result < T , E > ;
4954}
5055
You can’t perform that action at this time.
0 commit comments