@@ -248,7 +248,7 @@ var runCmd = &cobra.Command{
248248 )
249249
250250 // Load plugins and register their hooks.
251- pluginRegistry .LoadPlugins (runCtx , conf .Plugin .Plugins )
251+ pluginRegistry .LoadPlugins (runCtx , conf .Plugin .Plugins , conf . Plugin . StartTimeout )
252252
253253 // Start the metrics merger if enabled.
254254 var metricsMerger * metrics.Merger
@@ -295,7 +295,7 @@ var runCmd = &cobra.Command{
295295 logger .Info ().Str ("name" , pluginId .Name ).Msg ("Reloading crashed plugin" )
296296 pluginConfig := conf .Plugin .GetPlugins (pluginId .Name )
297297 if pluginConfig != nil {
298- pluginRegistry .LoadPlugins (runCtx , pluginConfig )
298+ pluginRegistry .LoadPlugins (runCtx , pluginConfig , conf . Plugin . StartTimeout )
299299 }
300300 } else {
301301 logger .Trace ().Str ("name" , pluginId .Name ).Msg ("Successfully pinged plugin" )
@@ -415,7 +415,15 @@ var runCmd = &cobra.Command{
415415
416416 // Check if the metrics server is already running before registering the handler.
417417 if _ , err = http .Get (address ); err != nil { //nolint:gosec
418- mux .Handle (metricsConfig .Path , gziphandler .GzipHandler (handler ))
418+ // The timeout handler limits the nested handlers from running for too long.
419+ mux .Handle (
420+ metricsConfig .Path ,
421+ http .TimeoutHandler (
422+ gziphandler .GzipHandler (handler ),
423+ metricsConfig .GetTimeout (),
424+ "The request timed out while fetching the metrics" ,
425+ ),
426+ )
419427 } else {
420428 logger .Warn ().Msg ("Metrics server is already running, consider changing the port" )
421429 span .RecordError (err )
@@ -426,9 +434,16 @@ var runCmd = &cobra.Command{
426434 Addr : metricsConfig .Address ,
427435 Handler : mux ,
428436 ReadHeaderTimeout : metricsConfig .GetReadHeaderTimeout (),
437+ ReadTimeout : metricsConfig .GetTimeout (),
438+ WriteTimeout : metricsConfig .GetTimeout (),
439+ IdleTimeout : metricsConfig .GetTimeout (),
429440 }
430441
431- logger .Info ().Str ("address" , address ).Msg ("Metrics are exposed" )
442+ logger .Info ().Fields (map [string ]interface {}{
443+ "address" : address ,
444+ "timeout" : metricsConfig .GetTimeout ().String (),
445+ "readHeaderTimeout" : metricsConfig .GetReadHeaderTimeout ().String (),
446+ }).Msg ("Metrics are exposed" )
432447
433448 if metricsConfig .CertFile != "" && metricsConfig .KeyFile != "" {
434449 // Set up TLS.
@@ -507,11 +522,21 @@ var runCmd = &cobra.Command{
507522 clients [name ].ReceiveTimeout = clients [name ].GetReceiveTimeout ()
508523 clients [name ].SendDeadline = clients [name ].GetSendDeadline ()
509524 clients [name ].ReceiveChunkSize = clients [name ].GetReceiveChunkSize ()
525+ clients [name ].DialTimeout = clients [name ].GetDialTimeout ()
510526
511527 // Add clients to the pool.
512528 for i := 0 ; i < cfg .GetSize (); i ++ {
513529 clientConfig := clients [name ]
514- client := network .NewClient (runCtx , clientConfig , logger )
530+ client := network .NewClient (
531+ runCtx , clientConfig , logger ,
532+ network .NewRetry (
533+ clientConfig .Retries ,
534+ clientConfig .GetBackoff (),
535+ clientConfig .BackoffMultiplier ,
536+ clientConfig .DisableBackoffCaps ,
537+ loggers [name ],
538+ ),
539+ )
515540
516541 if client != nil {
517542 eventOptions := trace .WithAttributes (
@@ -522,10 +547,15 @@ var runCmd = &cobra.Command{
522547 attribute .String ("receiveDeadline" , client .ReceiveDeadline .String ()),
523548 attribute .String ("receiveTimeout" , client .ReceiveTimeout .String ()),
524549 attribute .String ("sendDeadline" , client .SendDeadline .String ()),
550+ attribute .String ("dialTimeout" , client .DialTimeout .String ()),
525551 attribute .Bool ("tcpKeepAlive" , client .TCPKeepAlive ),
526552 attribute .String ("tcpKeepAlivePeriod" , client .TCPKeepAlivePeriod .String ()),
527553 attribute .String ("localAddress" , client .LocalAddr ()),
528554 attribute .String ("remoteAddress" , client .RemoteAddr ()),
555+ attribute .Int ("retries" , clientConfig .Retries ),
556+ attribute .String ("backoff" , clientConfig .GetBackoff ().String ()),
557+ attribute .Float64 ("backoffMultiplier" , clientConfig .BackoffMultiplier ),
558+ attribute .Bool ("disableBackoffCaps" , clientConfig .DisableBackoffCaps ),
529559 )
530560 if client .ID != "" {
531561 eventOptions = trace .WithAttributes (
@@ -547,8 +577,15 @@ var runCmd = &cobra.Command{
547577 "receiveDeadline" : client .ReceiveDeadline .String (),
548578 "receiveTimeout" : client .ReceiveTimeout .String (),
549579 "sendDeadline" : client .SendDeadline .String (),
580+ "dialTimeout" : client .DialTimeout .String (),
550581 "tcpKeepAlive" : client .TCPKeepAlive ,
551582 "tcpKeepAlivePeriod" : client .TCPKeepAlivePeriod .String (),
583+ "localAddress" : client .LocalAddr (),
584+ "remoteAddress" : client .RemoteAddr (),
585+ "retries" : clientConfig .Retries ,
586+ "backoff" : clientConfig .GetBackoff ().String (),
587+ "backoffMultiplier" : clientConfig .BackoffMultiplier ,
588+ "disableBackoffCaps" : clientConfig .DisableBackoffCaps ,
552589 }
553590 _ , err := pluginRegistry .Run (
554591 pluginTimeoutCtx , clientCfg , v1 .HookName_HOOK_NAME_ON_NEW_CLIENT )
0 commit comments