surafel58 opened a new pull request, #11797:
URL: https://github.com/apache/seatunnel/pull/11797

   ### Purpose of this pull request
   
   Follow-up to the review discussion on #11778 (raised by @nzw921rx and 
@DanielLeens).
   
   `PrometheusSinkConfig.loadConfig()` set `batch_size` only when the key was 
present, guarded by
   `getOptional(BATCH_SIZE).isPresent()`. `ReadonlyConfig.getOptional()` does 
not fall back to the
   option's declared default (only `get()` does, via 
`getOptional(option).orElseGet(option::defaultValue)`).
   So a job that omits `batch_size` ended up with `batchSize = 0`, and the 
size-based flush trigger in
   the writer (`batchSize > 0 && batchList.size() >= batchSize`) never fired. 
The declared default of
   `1024` in `PrometheusSinkOptions.BATCH_SIZE` was effectively ignored.
   
   This PR uses `get()` so the declared default is applied when `batch_size` is 
not configured.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, a bug fix. A `Prometheus` sink that does not set `batch_size` now 
buffers up to the documented
   default of `1024` rows before a size-based flush, instead of never flushing 
by size (`batchSize = 0`).
   Jobs that explicitly set `batch_size` are unaffected.
   
   ### How was this patch tested?
   
   Added `PrometheusSinkConfigTest` with three cases:
   
   - `batch_size` not configured -> `loadConfig` returns the declared default 
(`1024`);
   - `batch_size` configured -> that value is used;
   - `batch_size` non-positive -> rejected by the existing `checkArgument` 
guard.
   
   ```
   ./mvnw -pl seatunnel-connectors-v2/connector-prometheus test
   => Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
   ```
   
   ### Check list
   
   * [x] Code changed are covered with tests.
   * [ ] If any new Jar binary package adding in your PR, please add License 
Notice — N/A.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to