mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	feat(router_env): making metric flow as a trait for extensibility (#797)
This commit is contained in:
		| @ -1,6 +1,9 @@ | |||||||
| use super::utils as metric_utils; | use super::utils as metric_utils; | ||||||
|  |  | ||||||
| pub async fn record_request_time_metric<F, R>(future: F, flow: router_env::Flow) -> R | pub async fn record_request_time_metric<F, R>( | ||||||
|  |     future: F, | ||||||
|  |     flow: impl router_env::types::FlowMetric, | ||||||
|  | ) -> R | ||||||
| where | where | ||||||
|     F: futures::Future<Output = R>, |     F: futures::Future<Output = R>, | ||||||
| { | { | ||||||
|  | |||||||
| @ -522,7 +522,7 @@ where | |||||||
|     fields(request_method, request_url_path) |     fields(request_method, request_url_path) | ||||||
| )] | )] | ||||||
| pub async fn server_wrap<'a, 'b, A, T, U, Q, F, Fut, E>( | pub async fn server_wrap<'a, 'b, A, T, U, Q, F, Fut, E>( | ||||||
|     flow: router_env::Flow, |     flow: impl router_env::types::FlowMetric, | ||||||
|     state: &'b A, |     state: &'b A, | ||||||
|     request: &'a HttpRequest, |     request: &'a HttpRequest, | ||||||
|     payload: T, |     payload: T, | ||||||
|  | |||||||
| @ -164,6 +164,12 @@ pub enum Flow { | |||||||
|     ApiKeyList, |     ApiKeyList, | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /// | ||||||
|  | /// Trait for providing generic behaviour to flow metric | ||||||
|  | /// | ||||||
|  | pub trait FlowMetric: ToString + std::fmt::Debug {} | ||||||
|  | impl FlowMetric for Flow {} | ||||||
|  |  | ||||||
| /// Category of log event. | /// Category of log event. | ||||||
| #[derive(Debug)] | #[derive(Debug)] | ||||||
| pub enum Category { | pub enum Category { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Nishant Joshi
					Nishant Joshi