@@ -274,14 +274,8 @@ func (cfg *Config) Validate() error {
274274 if cfg .Retry .MaxRetries < 0 {
275275 return errors .New ("retry::max_retries should be non-negative" )
276276 }
277- if cfg .Batcher .Enabled != nil {
278- batcherConfig := exporterbatcher.Config {
279- Enabled : * cfg .Batcher .Enabled ,
280- FlushTimeout : cfg .Batcher .FlushTimeout ,
281- MinSizeConfig : cfg .Batcher .MinSizeConfig ,
282- MaxSizeConfig : cfg .Batcher .MaxSizeConfig ,
283- }
284- if err := batcherConfig .Validate (); err != nil {
277+ if batcherCfg , ok := cfg .exporterbatcherConfig (); ok {
278+ if err := batcherCfg .Validate (); err != nil {
285279 return fmt .Errorf ("invalid batcher config: %w" , err )
286280 }
287281 }
@@ -325,6 +319,18 @@ func (cfg *Config) endpoints() ([]string, error) {
325319 return endpoints , nil
326320}
327321
322+ func (cfg * Config ) exporterbatcherConfig () (exporterbatcher.Config , bool ) {
323+ if cfg .Batcher .Enabled == nil {
324+ return exporterbatcher.Config {}, false
325+ }
326+ return exporterbatcher.Config {
327+ Enabled : * cfg .Batcher .Enabled ,
328+ FlushTimeout : cfg .Batcher .FlushTimeout ,
329+ MinSizeConfig : cfg .Batcher .MinSizeConfig ,
330+ MaxSizeConfig : cfg .Batcher .MaxSizeConfig ,
331+ }, true
332+ }
333+
328334func validateEndpoint (endpoint string ) error {
329335 if endpoint == "" {
330336 return errConfigEmptyEndpoint
0 commit comments