Skip to content
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

[exporter/logging] Add syscall.EBADF to list of known sync errors #5585

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[exporter/logging] Add syscall.EBADF to list of known sync errors
  • Loading branch information
mx-psi committed Jun 23, 2022
commit 6be86735bfe72eee06b269a0631f06c08712e8bd
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### 💡 Enhancements 💡

- `exporter/logging`: Skip "bad file descriptor" sync errors (#TODO)

## v0.54.0 Beta

### 🛑 Breaking changes 🛑
Expand Down
28 changes: 19 additions & 9 deletions exporter/loggingexporter/known_sync_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,24 @@ import (
)

// knownSyncError returns true if the given error is one of the known
// non-actionable errors returned by Sync on Linux and macOS:
//
// Linux:
// - sync /dev/stdout: invalid argument
//
// macOS:
// - sync /dev/stdout: inappropriate ioctl for device
//
// non-actionable errors returned by Sync on Linux and macOS.
func knownSyncError(err error) bool {
return errors.Is(err, syscall.EINVAL) || errors.Is(err, syscall.ENOTSUP) || errors.Is(err, syscall.ENOTTY)
var knownSyncErrors = []error{
// sync /dev/stdout: invalid argument
syscall.EINVAL,
// sync /dev/stdout: not supported
syscall.ENOTSUP,
// sync /dev/stdout: inappropriate ioctl for device
syscall.ENOTTY,
// sync /dev/stdout: bad file descriptor
syscall.EBADF,
}
mx-psi marked this conversation as resolved.
Show resolved Hide resolved

for _, syncError := range knownSyncErrors {
if errors.Is(err, syncError) {
return true
}
}

return false
}