Description
I am working on building a pdh exporter for prometheus. Currently when my application initiates it calls the win.PdhValidatePath() function approximately 3000 times. Most of the calls succeed, however, some fail inconsistently.
I've discovered that the errors that are occurring are the following:
- "The system could not find the environment option that was entered."
- "The data area passed to a system call is too small.")
- "There are no more files."
- "Access is denied."
For all pdh counters that result in the errors above, if I try to collect them individually then no errors occur. The errors only occur when large amounts of pdh counters are using the PdhValidatePath() function. I do not have the PdhValidatePath() function inside of a Go routine, so concurrency should not be the problem here.
Any ideas on how to fix this? One solution I found online that wasn't officially answered suggested using the PdhValidatePathEx function rather than PdhValidatePath.
Thought I'd ask here before going down that path in case I am doing something wrong. If you want to see my code, it can be seen here.