-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add refresh list of perf counters at every fetch #13344
Conversation
Hi @narph , |
childQueries, err := r.query.ExpandWildCardPath(counter.Query) | ||
if err == nil && len(childQueries) >= 1 && !strings.Contains(childQueries[0], "*") { | ||
for _, v := range childQueries { | ||
if err := r.query.AddCounter(v, counter, len(childQueries) > 1); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also remove counters at some moment to avoid leaks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the line below query.Close()
I am running the PdhCloseQuery function which should close all counters contained in the specified query, closes all handles related to the query, and should free all memory associated with the query.
https://docs.microsoft.com/en-us/windows/win32/api/pdh/nf-pdh-pdhclosequery
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But query.Close()
is only executed if AddCounter
fails. Shouldn't we do some cleanup of old counters during the normal operation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed the close query and added the option to compare counters and remove older ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍
childQueries, err := r.query.ExpandWildCardPath(counter.Query) | ||
if err == nil && len(childQueries) >= 1 && !strings.Contains(childQueries[0], "*") { | ||
for _, v := range childQueries { | ||
if err := r.query.AddCounter(v, counter, len(childQueries) > 1); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But query.Close()
is only executed if AddCounter
fails. Shouldn't we do some cleanup of old counters during the normal operation?
if err == nil && len(childQueries) >= 1 && !strings.Contains(childQueries[0], "*") { | ||
for _, v := range childQueries { | ||
if err := r.query.AddCounter(v, counter, len(childQueries) > 1); err != nil { | ||
r.query.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RefreshCounterPaths()
is run on every fetch after the first one. If AddCounter
fails, r.query
will be closed and never reopened. Will then all the subsequent fetches fail because the query is closed?
I think that we shouldn't close here, or if we do it, we should have some reopening logic during fetch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch @jsoriano , I used to call OpenQuery at each refresh but moved it out, I have removed the close option.
childQueries, err := r.query.ExpandWildCardPath(counter.Query) | ||
if err == nil && len(childQueries) >= 1 && !strings.Contains(childQueries[0], "*") { | ||
for _, v := range childQueries { | ||
if err := r.query.AddCounter(v, counter, len(childQueries) > 1); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍
jenkins test this |
In the perfmon metricset the list of performance counters is calculated when the metricset starts, then cached.
If users use wildcards in their counter queries they expect to see counter values for the processes/instances that match those queries as well.
For this a refresh of the list should be added (maybe at every Fetch).
Should fix #13091
How to test: