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 all commits
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
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
}