File tree Expand file tree Collapse file tree 1 file changed +22
-11
lines changed
crates/datadog-metrics-collector/src Expand file tree Collapse file tree 1 file changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -69,19 +69,30 @@ fn read_cgroup_stats() -> CgroupStats {
6969 debug ! ( "Could not read scheduler period from {CGROUP_CPU_PERIOD_PATH}" ) ;
7070 }
7171
72- let scheduler_quota = fs:: read_to_string ( CGROUP_CPU_QUOTA_PATH )
73- . ok ( )
74- . and_then ( |contents| {
75- contents. trim ( ) . parse :: < i64 > ( ) . ok ( ) . and_then ( |quota| {
76- // Convert from microseconds to nanoseconds
77- if quota == -1 {
78- debug ! ( "CFS scheduler quota is -1, setting to None" ) ;
72+ let scheduler_quota = match fs:: read_to_string ( CGROUP_CPU_QUOTA_PATH ) {
73+ Ok ( contents) => {
74+ let trimmed = contents. trim ( ) ;
75+ match trimmed. parse :: < i64 > ( ) {
76+ Ok ( quota) => {
77+ // Convert from microseconds to nanoseconds
78+ if quota == -1 {
79+ debug ! ( "CFS scheduler quota is -1, setting to None" ) ;
80+ None
81+ } else {
82+ Some ( ( quota * 1000 ) as u64 )
83+ }
84+ }
85+ Err ( e) => {
86+ debug ! ( "Could not parse scheduler quota from {CGROUP_CPU_QUOTA_PATH}: {e}" ) ;
7987 None
80- } else {
81- Some ( ( quota * 1000 ) as u64 )
8288 }
83- } )
84- } ) ;
89+ }
90+ }
91+ Err ( e) => {
92+ debug ! ( "Could not read scheduler quota from {CGROUP_CPU_QUOTA_PATH}: {e}" ) ;
93+ None
94+ }
95+ } ;
8596
8697 CgroupStats {
8798 total,
You can’t perform that action at this time.
0 commit comments