@@ -118,6 +118,11 @@ pub struct Config {
118118 pub target_metrics : Option < Vec < target_metrics:: Config > > ,
119119 /// The target inspector sub-program
120120 pub inspector : Option < inspector:: Config > ,
121+ /// When true, raise the open file descriptor limit (`RLIMIT_NOFILE`) to
122+ /// infinity on startup. Raising the hard limit requires `CAP_SYS_RESOURCE`.
123+ /// Default is false.
124+ #[ serde( default ) ]
125+ pub maximize_open_file_limit : bool ,
121126}
122127
123128/// Partial configuration used for merging multiple config files
@@ -147,6 +152,8 @@ pub struct PartialConfig {
147152 pub target_metrics : Option < Vec < target_metrics:: Config > > ,
148153 /// The target inspector sub-program.
149154 pub inspector : Option < inspector:: Config > ,
155+ /// When true, raise `RLIMIT_NOFILE` to infinity on startup.
156+ pub maximize_open_file_limit : Option < bool > ,
150157}
151158
152159/// Default value for [`Telemetry::Log`] expiration
@@ -280,6 +287,7 @@ impl Config {
280287 blackhole : partial. blackhole ,
281288 target_metrics : partial. target_metrics ,
282289 inspector : partial. inspector ,
290+ maximize_open_file_limit : partial. maximize_open_file_limit . unwrap_or ( false ) ,
283291 } )
284292 }
285293
@@ -334,6 +342,11 @@ impl Config {
334342 base. observer = overlay. observer ;
335343 }
336344
345+ // Last writer wins for the file-descriptor limit toggle.
346+ if overlay. maximize_open_file_limit . is_some ( ) {
347+ base. maximize_open_file_limit = overlay. maximize_open_file_limit ;
348+ }
349+
337350 // Merge generators
338351 base. generator . extend ( overlay. generator ) ;
339352 check_duplicate_generator_ids ( & base. generator ) ?;
@@ -546,6 +559,7 @@ mod tests {
546559 blackhole : vec ! [ ] ,
547560 target_metrics : None ,
548561 inspector : None ,
562+ maximize_open_file_limit : None ,
549563 }
550564 }
551565
@@ -559,6 +573,7 @@ mod tests {
559573 blackhole : blackholes,
560574 target_metrics : None ,
561575 inspector : None ,
576+ maximize_open_file_limit : None ,
562577 }
563578 }
564579
@@ -572,6 +587,7 @@ mod tests {
572587 blackhole : vec ! [ ] ,
573588 target_metrics : Some ( metrics) ,
574589 inspector : None ,
590+ maximize_open_file_limit : None ,
575591 }
576592 }
577593
@@ -660,6 +676,7 @@ blackhole:
660676 inspector: Option :: default ( ) ,
661677 target_metrics: Option :: default ( ) ,
662678 sample_period_milliseconds: 1_000 ,
679+ maximize_open_file_limit: false ,
663680 } ,
664681 ) ;
665682 Ok ( ( ) )
0 commit comments