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

Remove logging from the default error handler #2416

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Changed

- Changed the project minimum supported Go version from 1.15 to 1.16. (#2412)
- Remove logging from the default error handler. (#2416)

### Removed

Expand Down
7 changes: 1 addition & 6 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package otel // import "go.opentelemetry.io/otel"

import (
"log"
"os"
"sync"
"sync/atomic"
Expand All @@ -42,15 +41,13 @@ type holder struct {

func defaultErrorHandler() *atomic.Value {
v := &atomic.Value{}
v.Store(holder{eh: &delegator{l: log.New(os.Stderr, "", log.LstdFlags)}})
v.Store(holder{eh: &delegator{}})
return v
}

// delegator logs errors if no delegate is set, otherwise they are delegated.
type delegator struct {
delegate atomic.Value

l *log.Logger
}

// setDelegate sets the ErrorHandler delegate.
Expand All @@ -64,9 +61,7 @@ func (h *delegator) setDelegate(d ErrorHandler) {
func (h *delegator) Handle(err error) {
if d := h.delegate.Load(); d != nil {
d.(ErrorHandler).Handle(err)
return
}
h.l.Print(err)
}

// GetErrorHandler returns the global ErrorHandler instance.
Expand Down