node_exporter icon indicating copy to clipboard operation
node_exporter copied to clipboard

Add Collection Timeout

Open mitanshu001 opened this issue 7 months ago • 0 comments

Summary

This PR introduces a collection timeout feature to the Node Exporter. Posting the draft PR to get initial feedback, I will add an option to configure the timeout value. This will provide users with the flexibility to adjust the timeout based on their specific needs and environments(scrape timeout)

Need

If the time to collect metrics from any one collector is greater than scrape timeout than None of the other metrics are collected and results in false Node down alerts.

Timeout Implementation

  • Added a constant collectorTimeout
  • Utilized the context package to manage the timeout for each collector operation.
  • Implemented a buffered channel collectorCh to reduce blocking during metric collection.
  • Introduced an error channel errCh to capture errors from the Update function.
  • Enhanced error handling to log timeout-specific errors.

Testing Ensure that the timeout is enforced correctly and that appropriate logs are generated when a timeout occurs. Verify that metrics are collected and sent without blocking or errors.

mitanshu001 avatar Mar 16 '25 11:03 mitanshu001