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
…5585)

* [exporter/logging] Add `syscall.EBADF` to list of known sync errors

* Add PR number to changelog

* [exporter/logging] Make `knownSyncError` a global var
  • Loading branch information
mx-psi authored Jun 30, 2022
1 parent d63aea3 commit 5ead47c
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 @@ -12,6 +12,10 @@

- Deprecate `service.ConfigServiceTelemetry`, `service.ConfigServiceTelemetryLogs`, and `service.ConfigServiceTelemetryMetrics` (#5565)

### 💡 Enhancements 💡

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

### 🧰 Bug fixes 🧰

- Fix initialization of the OpenTelemetry MetricProvider. (#5571)
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 @@ -22,15 +22,25 @@ import (
"syscall"
)

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,
}

// 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)
for _, syncError := range knownSyncErrors {
if errors.Is(err, syncError) {
return true
}
}

return false
}

0 comments on commit 5ead47c

Please sign in to comment.