Skip to content

Commit

Permalink
[exporter/logging] Add syscall.EBADF to list of known sync errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mx-psi committed Jun 23, 2022
1 parent b094dbd commit 6be8673
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
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,
}

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

return false
}

0 comments on commit 6be8673

Please sign in to comment.