Skip to content

Commit

Permalink
Do not alloc multiple noop exporters (#5083)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias authored Mar 19, 2024
1 parent ca5bb1f commit 12c5651
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sdk/log/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ type Exporter interface {
ForceFlush(ctx context.Context) error
}

var defaultNoopExporter = &noopExporter{}

type noopExporter struct{}

func (noopExporter) Export(context.Context, []Record) error { return nil }
Expand Down
2 changes: 1 addition & 1 deletion sdk/log/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type SimpleProcessor struct {
func NewSimpleProcessor(exporter Exporter) *SimpleProcessor {
if exporter == nil {
// Do not panic on nil exporter.
exporter = noopExporter{}
exporter = defaultNoopExporter
}
return &SimpleProcessor{exporter: exporter}
}
Expand Down

0 comments on commit 12c5651

Please sign in to comment.