-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessor.go
More file actions
79 lines (65 loc) · 1.77 KB
/
Copy pathprocessor.go
File metadata and controls
79 lines (65 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package processor
import (
"errors"
"log/slog"
"go.opentelemetry.io/otel/metric"
)
var (
ErrControlNotSupported = errors.New("control not supported")
ErrProcessorNotRunning = errors.New("processor not running")
ErrAlreadyRunning = errors.New("already running")
ErrAlreadyPaused = errors.New("already paused")
ErrProcessorBusy = errors.New("processor busy")
ErrUnableToStart = errors.New("unable to start")
ErrMultipleStart = errors.New("multiple start")
ErrMultipleStop = errors.New("multiple stop")
)
// SkipResult is a sentinel error that signals a processor should skip output generation
// for the current input. Effective for synchronous processors; async processors will
// log a warning as it doesn't affect their separate Output() channels.
var SkipResult = errors.New("skip result")
type config struct {
label *string
logger *slog.Logger
startPaused bool
blockOnOutput bool
useRoundRobinFanIn bool // TODO: warn if set on non-N processor
outputChannelSize int
meterProvider metric.MeterProvider
}
type Option func(*config)
func WithLogger(logger *slog.Logger) Option {
return func(c *config) {
c.logger = logger
}
}
func WithLabel(label string) Option {
return func(c *config) {
c.label = &label
}
}
func StartPaused() Option {
return func(c *config) {
c.startPaused = true
}
}
func BlockOnOutput() Option {
return func(c *config) {
c.blockOnOutput = true
}
}
func UseRoundRobinFanIn() Option {
return func(c *config) {
c.useRoundRobinFanIn = true
}
}
func WithOutputChannelSize(size int) Option {
return func(c *config) {
c.outputChannelSize = max(0, size)
}
}
func WithMeterProvider(mp metric.MeterProvider) Option {
return func(c *config) {
c.meterProvider = mp
}
}