@@ -25,6 +25,8 @@ const (
25
25
ContextPropagationDisabled
26
26
)
27
27
28
+ const bufferSizeMax = 8192
29
+
28
30
// EBPFTracer configuration for eBPF programs
29
31
type EBPFTracer struct {
30
32
// Enables logging of eBPF program events
@@ -103,9 +105,7 @@ type EBPFTracer struct {
103
105
}
104
106
105
107
// Per-protocol data buffer size in bytes.
106
- // Min: 128 bytes, Max: 8192 bytes.
107
- // Valid values: 0, 128, 256, 512, 1024, 2048, 4096, 8192.
108
- //
108
+ // Max: 8192 bytes.
109
109
// Default: 0 (disabled).
110
110
type EBPFBufferSizes struct {
111
111
HTTP uint32 `yaml:"http" env:"OTEL_EBPF_BPF_BUFFER_SIZE_HTTP"`
@@ -116,25 +116,14 @@ type EBPFBufferSizes struct {
116
116
func (c * EBPFTracer ) Validate () error {
117
117
// TODO(matt): validate all the existing attributes
118
118
119
- switch c .BufferSizes .HTTP {
120
- case 0 , 128 , 256 , 512 , 1024 , 2048 , 4096 , 8192 :
121
- // valid sizes
122
- default :
123
- return fmt .Errorf ("invalid HTTP buffer size: %d, must be one of 0, 128, 256, 512, 1024, 2048, 4096, 8192" , c .BufferSizes .HTTP )
119
+ if c .BufferSizes .HTTP > bufferSizeMax {
120
+ return fmt .Errorf ("buffer size too large (HTTP): %d, max is %d" , c .BufferSizes .HTTP , bufferSizeMax )
124
121
}
125
-
126
- switch c .BufferSizes .MySQL {
127
- case 0 , 128 , 256 , 512 , 1024 , 2048 , 4096 , 8192 :
128
- // valid sizes
129
- default :
130
- return fmt .Errorf ("invalid MySQL buffer size: %d, must be one of 0, 128, 256, 512, 1024, 2048, 4096, 8192" , c .BufferSizes .MySQL )
122
+ if c .BufferSizes .MySQL > bufferSizeMax {
123
+ return fmt .Errorf ("buffer size too large (MySQL): %d, max is %d" , c .BufferSizes .MySQL , bufferSizeMax )
131
124
}
132
-
133
- switch c .BufferSizes .Postgres {
134
- case 0 , 128 , 256 , 512 , 1024 , 2048 , 4096 , 8192 :
135
- // valid sizes
136
- default :
137
- return fmt .Errorf ("invalid Postgres buffer size: %d, must be one of 0, 128, 256, 512, 1024, 2048, 4096, 8192" , c .BufferSizes .Postgres )
125
+ if c .BufferSizes .Postgres > bufferSizeMax {
126
+ return fmt .Errorf ("buffer size too large (Postgres): %d, max is %d" , c .BufferSizes .Postgres , bufferSizeMax )
138
127
}
139
128
140
129
return nil
0 commit comments