Copilot commented on code in PR #13544:
URL: https://github.com/apache/skywalking/pull/13544#discussion_r2431447810
##########
oap-server/server-library/library-elasticsearch-client/src/main/java/org/apache/skywalking/library/elasticsearch/bulk/BulkProcessor.java:
##########
@@ -132,13 +136,16 @@ public void flush() {
log.error("Interrupted when trying to get semaphore to execute
bulk requests", e);
return;
}
-
+ HistogramMetrics.Timer timer = bulkMetrics.createTimer();
final List<Holder> batch = new ArrayList<>(requests.size());
requests.drainTo(batch);
final List<CompletableFuture<Void>> futures = doFlush(batch);
final CompletableFuture<Void> future = CompletableFuture.allOf(
futures.toArray(new CompletableFuture[futures.size()]));
- future.whenComplete((v, t) -> semaphore.release());
+ future.whenComplete((v, t) -> {
+ timer.close();
+ semaphore.release();
+ });
future.join();
lastFlushTS = System.currentTimeMillis();
Review Comment:
Timer should be created inside the try-with-resources statement to ensure
proper resource management and timing accuracy.
##########
oap-server/server-library/library-elasticsearch-client/src/main/java/org/apache/skywalking/library/elasticsearch/bulk/BulkProcessorBuilder.java:
##########
@@ -57,8 +59,14 @@ public BulkProcessorBuilder concurrentRequests(int
concurrentRequests) {
return this;
}
+ public BulkProcessorBuilder bulkMetrics(HistogramMetrics bulkMetrics) {
Review Comment:
Extra space between 'public' and 'BulkProcessorBuilder' - should be single
space.
```suggestion
public BulkProcessorBuilder bulkMetrics(HistogramMetrics bulkMetrics) {
```
--
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]