Source File
simple.go
Belonging Package
go.opentelemetry.io/otel/sdk/log
// Copyright The OpenTelemetry Authors// SPDX-License-Identifier: Apache-2.0package log // import "go.opentelemetry.io/otel/sdk/log"import ()// Compile-time check SimpleProcessor implements Processor.var _ Processor = (*SimpleProcessor)(nil)// SimpleProcessor is an processor that synchronously exports log records.//// Use [NewSimpleProcessor] to create a SimpleProcessor.type SimpleProcessor struct {mu sync.Mutexexporter ExporternoCmp [0]func() //nolint: unused // This is indeed used.}// NewSimpleProcessor is a simple Processor adapter.//// This Processor is not recommended for production use due to its synchronous// nature, which makes it suitable for testing, debugging, or demonstrating// other features, but can lead to slow performance and high computational// overhead. For production environments, it is recommended to use// [NewBatchProcessor] instead. However, there may be exceptions where certain// [Exporter] implementations perform better with this Processor.func ( Exporter, ...SimpleProcessorOption) *SimpleProcessor {return &SimpleProcessor{exporter: }}var simpleProcRecordsPool = sync.Pool{New: func() any {:= make([]Record, 1)return &},}// OnEmit batches provided log record.func ( *SimpleProcessor) ( context.Context, *Record) error {if .exporter == nil {return nil}.mu.Lock()defer .mu.Unlock():= simpleProcRecordsPool.Get().(*[]Record)(*)[0] = *defer func() {simpleProcRecordsPool.Put()}()return .exporter.Export(, *)}// Shutdown shuts down the exporter.func ( *SimpleProcessor) ( context.Context) error {if .exporter == nil {return nil}return .exporter.Shutdown()}// ForceFlush flushes the exporter.func ( *SimpleProcessor) ( context.Context) error {if .exporter == nil {return nil}return .exporter.ForceFlush()}// SimpleProcessorOption applies a configuration to a [SimpleProcessor].type SimpleProcessorOption interface {apply()}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |