-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Use counter time in win perf counters #4267
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f518141
Trying to fix #4250 - added possibility to use timestamp from perf co…
vlastahajek 1afbfb2
Merge branch 'master' into vh-fix#4250
vlastahajek 6d13e8b
Fixed wrong merge
vlastahajek acd6efe
Add missing error handling to second loop
vlastahajek 708a06a
Added test for gather errors
vlastahajek ef35f0d
Stabilizing test
vlastahajek 524a5c0
Making test using timestamp from counters
vlastahajek 074e9dd
Small code beautification
vlastahajek 0e3bf11
Merge branch 'master' into vh-fix#4250
vlastahajek 4f40a2c
Improved error reporting
vlastahajek 9c3f34a
- better name for isKnowError function
vlastahajek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Improved error reporting
- Loading branch information
commit 4f40a2c46700f6d117bece500b456f719fdf4397
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -307,7 +307,7 @@ func (m *Win_PerfCounters) Gather(acc telegraf.Accumulator) error { | |
collectFields[instance][sanitizedChars.Replace(metric.counter)] = float32(value) | ||
} else { | ||
//ignore invalid data from as some counters from process instances returns this sometimes | ||
if phderr, ok := err.(*PdhError); ok && phderr.ErrorCode != PDH_INVALID_DATA && phderr.ErrorCode != PDH_CALC_NEGATIVE_VALUE { | ||
if !isKnowError(err) { | ||
return fmt.Errorf("error while getting value for counter %s: %v", metric.counterPath, err) | ||
} | ||
} | ||
|
@@ -349,7 +349,7 @@ func (m *Win_PerfCounters) Gather(acc telegraf.Accumulator) error { | |
} | ||
} else { | ||
//ignore invalid data from as some counters from process instances returns this sometimes | ||
if phderr, ok := err.(*PdhError); ok && phderr.ErrorCode != PDH_INVALID_DATA && phderr.ErrorCode != PDH_CALC_NEGATIVE_VALUE { | ||
if !isKnowError(err) { | ||
return fmt.Errorf("error while getting value for counter %s: %v", metric.counterPath, err) | ||
} | ||
} | ||
|
@@ -369,6 +369,14 @@ func (m *Win_PerfCounters) Gather(acc telegraf.Accumulator) error { | |
return nil | ||
} | ||
|
||
//returns true if err is an error we count with | ||
func isKnowError(err error) bool { | ||
if phderr, ok := err.(*PdhError); ok && (phderr.ErrorCode == PDH_INVALID_DATA || phderr.ErrorCode == PDH_CALC_NEGATIVE_VALUE || phderr.ErrorCode == PDH_CSTATUS_INVALID_DATA) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you line wrap this around 78 chars? |
||
return true | ||
} | ||
return false | ||
} | ||
|
||
func init() { | ||
inputs.Add("win_perf_counters", func() telegraf.Input { | ||
return &Win_PerfCounters{query: &PerformanceQueryImpl{}, CountersRefreshInterval: internal.Duration{Duration: time.Second * 60}} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you rename this function and redo the comment? I think based on your comment above maybe you could name it
isCounterDataError
. You can probably remove the comment above if this name is more precise.