2024-03-13 17:47:07 +01:00
|
|
|
// Copyright The OpenTelemetry Authors
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
|
|
package log // import "go.opentelemetry.io/otel/sdk/log"
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Processor handles the processing of log records.
|
|
|
|
|
//
|
|
|
|
|
// Any of the Processor's methods may be called concurrently with itself
|
|
|
|
|
// or with other methods. It is the responsibility of the Processor to manage
|
|
|
|
|
// this concurrency.
|
2024-08-22 09:12:23 -07:00
|
|
|
//
|
2025-02-18 22:35:14 +01:00
|
|
|
// See [FilterProcessor] for information about how a Processor can support filtering.
|
2024-03-13 17:47:07 +01:00
|
|
|
type Processor interface {
|
|
|
|
|
// OnEmit is called when a Record is emitted.
|
|
|
|
|
//
|
2024-03-15 08:15:44 -07:00
|
|
|
// OnEmit will be called independent of Enabled. Implementations need to
|
|
|
|
|
// validate the arguments themselves before processing.
|
|
|
|
|
//
|
2024-03-13 17:47:07 +01:00
|
|
|
// Implementation should not interrupt the record processing
|
|
|
|
|
// if the context is canceled.
|
|
|
|
|
//
|
|
|
|
|
// All retry logic must be contained in this function. The SDK does not
|
|
|
|
|
// implement any retry logic. All errors returned by this function are
|
|
|
|
|
// considered unrecoverable and will be reported to a configured error
|
|
|
|
|
// Handler.
|
|
|
|
|
//
|
2024-08-01 10:13:43 +02:00
|
|
|
// The SDK invokes the processors sequentially in the same order as
|
2025-02-18 22:35:14 +01:00
|
|
|
// they were registered using WithProcessor.
|
2024-08-01 10:13:43 +02:00
|
|
|
// Implementations may synchronously modify the record so that the changes
|
|
|
|
|
// are visible in the next registered processor.
|
2025-02-18 22:35:14 +01:00
|
|
|
// Notice that Record is not concurrent safe. Therefore, asynchronous
|
|
|
|
|
// processing may cause race conditions. Use Record.Clone
|
2024-03-13 17:47:07 +01:00
|
|
|
// to create a copy that shares no state with the original.
|
2024-08-01 10:13:43 +02:00
|
|
|
OnEmit(ctx context.Context, record *Record) error
|
2024-08-05 21:14:00 +02:00
|
|
|
|
2024-03-13 17:47:07 +01:00
|
|
|
// Shutdown is called when the SDK shuts down. Any cleanup or release of
|
|
|
|
|
// resources held by the exporter should be done in this call.
|
|
|
|
|
//
|
|
|
|
|
// The deadline or cancellation of the passed context must be honored. An
|
|
|
|
|
// appropriate error should be returned in these situations.
|
|
|
|
|
//
|
|
|
|
|
// After Shutdown is called, calls to Export, Shutdown, or ForceFlush
|
|
|
|
|
// should perform no operation and return nil error.
|
|
|
|
|
Shutdown(ctx context.Context) error
|
2024-08-05 21:14:00 +02:00
|
|
|
|
2024-03-13 17:47:07 +01:00
|
|
|
// ForceFlush exports log records to the configured Exporter that have not yet
|
|
|
|
|
// been exported.
|
|
|
|
|
//
|
|
|
|
|
// The deadline or cancellation of the passed context must be honored. An
|
|
|
|
|
// appropriate error should be returned in these situations.
|
|
|
|
|
ForceFlush(ctx context.Context) error
|
|
|
|
|
}
|