-
Notifications
You must be signed in to change notification settings - Fork 24
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
[system/process] add support for mutlierr #166
Merged
VihasMakwana
merged 28 commits into
elastic:main
from
VihasMakwana:multierror-enhancement
Jul 23, 2024
Merged
Changes from 17 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
9374d23
chore: initial commit, use errors.join
VihasMakwana f27b495
chore: introduce new helper, nits
VihasMakwana ed559b2
fix: clean the functino
VihasMakwana 0e93586
fix: add wrpped error
VihasMakwana 1a83875
fix: update tests
VihasMakwana ced452b
Merge branch 'main' into multierror-enhancement
VihasMakwana 63f95b8
fix: fix argument order
VihasMakwana 1b4ad46
fix: tests
VihasMakwana 6e2ab10
fix: update ListStates
VihasMakwana 3ccb849
fix: windows support
VihasMakwana 557c766
fix: verbose
VihasMakwana 00fd657
fix: verbose
VihasMakwana 13e6bf0
chore: update container tests
VihasMakwana 8aa9dd0
chore: add helper
VihasMakwana 5049500
chore: remame function
VihasMakwana 82526c3
fix: comments
VihasMakwana 33f4f40
chore: add comments
VihasMakwana a4b22de
simplify build tags
VihasMakwana c1f9abd
fix: don't exported canIgnore
VihasMakwana a98038a
Update metric/system/process/process.go
VihasMakwana 6a7cb8a
chore: simplify code. remove helpers
VihasMakwana 6c2f29e
fix: add wrappers and unwrap for recusive lookup
VihasMakwana ceb1dff
fix: fix bug, nil pointer
VihasMakwana 4cada94
fix: bug, nil pointer
VihasMakwana 0d0ff39
fix: nits
VihasMakwana 30a6fa5
chore: add test cases
VihasMakwana 7db28ef
chore: comments
VihasMakwana b020a9d
fix: add license
VihasMakwana 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
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
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
//go:build darwin || freebsd || linux || aix || netbsd || openbsd | ||
VihasMakwana marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
package process | ||
|
||
import ( | ||
"errors" | ||
"syscall" | ||
) | ||
|
||
func CanDegrade(err error) bool { | ||
VihasMakwana marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Check for errors which aren't fatal in nature and would be only used to change status to DEGRADED by metricbeat | ||
if err == nil { | ||
return true | ||
} | ||
return (errors.Is(err, syscall.EACCES) || | ||
errors.Is(err, syscall.EPERM) || | ||
errors.Is(err, syscall.EINVAL) || | ||
errors.Is(err, NonFatalErr{})) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
//go:build windows | ||
|
||
package process | ||
|
||
import ( | ||
"errors" | ||
"syscall" | ||
|
||
"golang.org/x/sys/windows" | ||
) | ||
|
||
func CanDegrade(err error) bool { | ||
// Check for errors which aren't fatal in nature and would be only used to change status to DEGRADED by metricbeat | ||
if err == nil { | ||
return true | ||
} | ||
return (errors.Is(err, windows.ERROR_ACCESS_DENIED) || | ||
errors.Is(err, syscall.EPERM) || | ||
errors.Is(err, syscall.EINVAL) || | ||
errors.Is(err, windows.ERROR_INVALID_PARAMETER) || | ||
errors.Is(err, NonFatalErr{})) | ||
} |
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
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
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
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
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
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
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
Oops, something went wrong.
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.
Does this need to be exported, as it seems to be used from within the same package?
Same goes for
CanDegrade
.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.
Hi,
Regarding
CanDegrade
, we use this helper in metricbeat here.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.
Also, @ycombinator we will also use
CanDegrade
here to ignore non-fatal errors.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've made
CanIgnore
local to this package.