Debian Codegraph @

exporter/exporterhelper/queue_batch.go

raw symbols SCIP
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package exporterhelper // import "go.opentelemetry.io/collector/exporter/exporterhelper"
5
6 import (
7 "context"
8
9 "go.opentelemetry.io/collector/exporter/exporterhelper/internal"
10 "go.opentelemetry.io/collector/exporter/exporterhelper/internal/queue"
11 "go.opentelemetry.io/collector/exporter/exporterhelper/internal/queuebatch"
12 )
13
14 // WithQueue overrides the default QueueBatchConfig for an exporter.
15 // The default QueueBatchConfig is to disable queueing.
16 // This option cannot be used with the new exporter helpers New[Traces|Metrics|Logs]RequestExporter.
17 func WithQueue(config QueueBatchConfig) Option {
18 return internal.WithQueue(config)
19 }
20
21 // QueueBatchConfig defines configuration for queueing and batching for the exporter.
22 type QueueBatchConfig = queuebatch.Config
23
24 // BatchConfig defines a configuration for batching requests based on a timeout and a minimum number of items.
25 type BatchConfig = queuebatch.BatchConfig
26
27 // QueueBatchEncoding defines the encoding to be used if persistent queue is configured.
28 // Duplicate definition with queuebatch.Encoding since aliasing generics is not supported by default.
29 type QueueBatchEncoding[T any] interface {
30 // Marshal is a function that can marshal a request and its context into bytes.
31 Marshal(context.Context, T) ([]byte, error)
32
33 // Unmarshal is a function that can unmarshal bytes into a request and its context.
34 Unmarshal([]byte) (context.Context, T, error)
35 }
36
37 var ErrQueueIsFull = queue.ErrQueueIsFull
38
39 // NewDefaultQueueConfig returns the default config for QueueBatchConfig.
40 // By default, the queue stores 1000 requests of telemetry and is non-blocking when full.
41 var NewDefaultQueueConfig = internal.NewDefaultQueueConfig