# Number must be positive. (Parameter 'batchSize')

**URL:** <https://discuss.elastic.co/t/number-must-be-positive-parameter-batchsize/362286>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [July 1, 2024, 10:05am UTC](https://discuss.elastic.co/t/number-must-be-positive-parameter-batchsize/362286 "2024-07-01T10:05:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![monty241](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/monty241/32/81681_2.png) [@monty241](https://discuss.elastic.co/u/monty241)\
**Post date:** [July 1, 2024, 10:05am UTC](https://discuss.elastic.co/t/number-must-be-positive-parameter-batchsize/362286/1 "2024-07-01T10:05:33Z")

</div>

Note for other people running into the error:

```auto
Number must be positive. (Parameter 'batchSize')

```

when executing `AgentComponents agentComponents = new AgentComponents(elasticApmLogger, elasticApmConfig, null);`

## Solution

The reason is that `MaxBatchEventCount` in the IConfigurationReader implementation is 0. The documentation on the interface states:

> The maximal number of events to send in a batch.  
> It's possible for a batch contain less then the maximum events  
> if there are events that need to be sent out because they were held for too long.
> 
> - Positive number - The maximal number of of events to send in a batch.
> - 0 and negative - Invalid and the default value is used instead.

However, a value of zero will raise the error `Number must be positive.`

Using a negative value also raises `Number must be positive`.

Replace the value of the configuration option by a positive value like the default value 10 (see `ConfigConsts.cs` in the class `DefaultValues`).
