1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-03-23 21:19:35 +02:00

Do not alloc multiple noop exporters (#5083)

This commit is contained in:
Tyler Yahn 2024-03-19 10:33:57 -07:00 committed by GitHub
parent ca5bb1f54c
commit 12c5651ec7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

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

View File

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