SumoLogic / sumologic-java-http-core

Core Java components for sending data to Sumo Logic HTTP sources
Apache License 2.0
2 stars 4 forks source link

BufferFlushingTask now honors messagesPerRequest when flushing #24

Closed mccartney closed 2 years ago

mccartney commented 2 years ago

Why: Discovered with seemingly unrelated code change. SumoHttpSenderTest.testRetryRegex() has failed semi-deterministically (quite deterministic per machine, per JDK version, for some machines) with:

[ERROR] testRetryRegex(com.sumologic.http.sender.SumoHttpSenderTest)  Time elapsed: 2.063 s  <<< FAILURE!
java.lang.AssertionError: expected:<2> but was:<1>
    at com.sumologic.http.sender.SumoHttpSenderTest.testRetryRegex(SumoHttpSenderTest.java:278)

It turned out flushAndSend() didn't honor the messagesPerRequest setting. Thus sometimes (depending on how quickly the messages appeared in the input queue) it sent more than 1 message in one go.

Which was not what SumoHttpSenderTest.testRetryRegex() was expecting. Also I suppose legitimate/production code setting the messagesPerRequest wouldn't want to see more messages sent.

What: BufferFlushingTask on flush sends at most messagesPerRequest in one go.

codecov-commenter commented 2 years ago

Codecov Report

Merging #24 (72bf6dc) into master (2ec992d) will increase coverage by 0.59%. The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #24      +/-   ##
============================================
+ Coverage     61.63%   62.22%   +0.59%     
- Complexity       65       66       +1     
============================================
  Files             9        9              
  Lines           318      323       +5     
  Branches         27       28       +1     
============================================
+ Hits            196      201       +5     
  Misses          108      108              
  Partials         14       14              
Impacted Files Coverage Δ
...a/com/sumologic/http/queue/BufferWithEviction.java 66.66% <ø> (ø)
.../sumologic/http/sender/SumoBufferFlushingTask.java 90.47% <ø> (ø)
...sumologic/http/aggregation/BufferFlushingTask.java 93.10% <100.00%> (+1.43%) :arrow_up:
.../sumologic/http/aggregation/SumoBufferFlusher.java 92.30% <100.00%> (ø)
...m/sumologic/http/queue/BufferWithFifoEviction.java 80.76% <100.00%> (ø)
...mologic/http/queue/CostBoundedConcurrentQueue.java 88.88% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2ec992d...72bf6dc. Read the comment docs.