mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	feat(router_env): add sampling_rate for traces (#335)
This commit is contained in:
		| @ -63,6 +63,11 @@ log_format = "default"  # Log format. "default" or "json" | |||||||
| # defaults to "WARN" | # defaults to "WARN" | ||||||
| level = "DEBUG" | level = "DEBUG" | ||||||
|  |  | ||||||
|  | # Telemetry configuration for traces | ||||||
|  | [log.telemetry] | ||||||
|  | enabled = false # boolean [true or false] | ||||||
|  | sampling_rate = 0.1 # decimal rate between 0.0 - 1.0 | ||||||
|  |  | ||||||
| # This section provides configuration details for using AWS KMS to encrypt | # This section provides configuration details for using AWS KMS to encrypt | ||||||
| # data like payment method details being sent over a network. | # data like payment method details being sent over a network. | ||||||
| [keys] | [keys] | ||||||
|  | |||||||
| @ -90,6 +90,8 @@ pub struct LogConsole { | |||||||
| pub struct LogTelemetry { | pub struct LogTelemetry { | ||||||
|     /// Whether tracing/telemetry is enabled. |     /// Whether tracing/telemetry is enabled. | ||||||
|     pub enabled: bool, |     pub enabled: bool, | ||||||
|  |     /// Sampling rate for traces | ||||||
|  |     pub sampling_rate: Option<f64>, | ||||||
| } | } | ||||||
|  |  | ||||||
| /// Telemetry / tracing. | /// Telemetry / tracing. | ||||||
|  | |||||||
| @ -42,6 +42,9 @@ pub fn setup<Str: AsRef<str>>( | |||||||
|  |  | ||||||
|     let telemetry = if conf.telemetry.enabled { |     let telemetry = if conf.telemetry.enabled { | ||||||
|         let trace_config = trace::config() |         let trace_config = trace::config() | ||||||
|  |             .with_sampler(trace::Sampler::TraceIdRatioBased( | ||||||
|  |                 conf.telemetry.sampling_rate.unwrap_or(1.0), | ||||||
|  |             )) | ||||||
|             .with_resource(Resource::new(vec![KeyValue::new("service.name", "router")])); |             .with_resource(Resource::new(vec![KeyValue::new("service.name", "router")])); | ||||||
|         let tracer = opentelemetry_otlp::new_pipeline() |         let tracer = opentelemetry_otlp::new_pipeline() | ||||||
|             .tracing() |             .tracing() | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Sampras Lopes
					Sampras Lopes