File tree Expand file tree Collapse file tree 3 files changed +68
-9
lines changed Expand file tree Collapse file tree 3 files changed +68
-9
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright The OpenTelemetry Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ // +build !windows
16
+
17
+ package loggingexporter
18
+
19
+ import (
20
+ "syscall"
21
+ )
22
+
23
+ // knownSyncError returns true if the given error is one of the known
24
+ // non-actionable errors returned by Sync on Linux and macOS:
25
+ //
26
+ // Linux:
27
+ // - sync /dev/stdout: invalid argument
28
+ //
29
+ // macOS:
30
+ // - sync /dev/stdout: inappropriate ioctl for device
31
+ //
32
+ func knownSyncError (err error ) bool {
33
+ switch err {
34
+ case syscall .EINVAL , syscall .ENOTSUP , syscall .ENOTTY :
35
+ return true
36
+ }
37
+ return false
38
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright The OpenTelemetry Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ // +build windows
16
+
17
+ package loggingexporter
18
+
19
+ import "golang.org/x/sys/windows"
20
+
21
+ // knownSyncError returns true if the given error is one of the known
22
+ // non-actionable errors returned by Sync on Windows:
23
+ //
24
+ // - sync /dev/stderr: The handle is invalid.
25
+ //
26
+ func knownSyncError (err error ) bool {
27
+ return err == windows .ERROR_INVALID_HANDLE
28
+ }
Original file line number Diff line number Diff line change @@ -20,7 +20,6 @@ import (
20
20
"os"
21
21
"strconv"
22
22
"strings"
23
- "syscall"
24
23
25
24
"go.uber.org/zap"
26
25
@@ -507,18 +506,12 @@ func (s *loggingExporter) pushLogData(
507
506
508
507
func loggerSync (logger * zap.Logger ) func (context.Context ) error {
509
508
return func (context.Context ) error {
510
- // Currently Sync() on stdout and stderr return errors on Linux and macOS,
511
- // respectively:
512
- //
513
- // - sync /dev/stdout: invalid argument
514
- // - sync /dev/stdout: inappropriate ioctl for device
515
- //
509
+ // Currently Sync() return a different error depending on the OS.
516
510
// Since these are not actionable ignore them.
517
511
err := logger .Sync ()
518
512
if osErr , ok := err .(* os.PathError ); ok {
519
513
wrappedErr := osErr .Unwrap ()
520
- switch wrappedErr {
521
- case syscall .EINVAL , syscall .ENOTSUP , syscall .ENOTTY :
514
+ if knownSyncError (wrappedErr ) {
522
515
err = nil
523
516
}
524
517
}
You can’t perform that action at this time.
0 commit comments