diff --git a/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/AtlasRegistry.java b/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/AtlasRegistry.java index 38fe289b6..f7e537400 100644 --- a/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/AtlasRegistry.java +++ b/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/AtlasRegistry.java @@ -310,7 +310,7 @@ void sendToLWC() { EvalPayload payload = evaluator.eval(t); if (!payload.getMetrics().isEmpty()) { List> futures = new ArrayList<>(); - payload.toBatches(batchSize, p -> futures.add(publisher.publish(p))); + payload.consumeBatches(batchSize, p -> futures.add(publisher.publish(p))); CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); } } catch (Exception e) { diff --git a/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/impl/EvalPayload.java b/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/impl/EvalPayload.java index 3a5c839a7..2c5cec998 100644 --- a/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/impl/EvalPayload.java +++ b/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/impl/EvalPayload.java @@ -70,9 +70,9 @@ public List getMessages() { * @return * List of payloads that have at most {@code batchSize} metrics per payload. */ - public List toBatches(int batchSize) { + public List consumeBatches(int batchSize) { List payloads = new ArrayList<>(metrics.size() / batchSize + 1); - toBatches(batchSize, payloads::add); + consumeBatches(batchSize, payloads::add); return payloads; } @@ -85,7 +85,7 @@ public List toBatches(int batchSize) { * @param consumer * Consumer to receive an eval payload batch. */ - public void toBatches(int batchSize, Consumer consumer) { + public void consumeBatches(int batchSize, Consumer consumer) { int size = metrics.size(); if (size <= batchSize) { consumer.accept(this); diff --git a/spectator-reg-atlas/src/test/java/com/netflix/spectator/atlas/impl/EvalPayloadTest.java b/spectator-reg-atlas/src/test/java/com/netflix/spectator/atlas/impl/EvalPayloadTest.java index 05fdf5b6c..9a2ca5e69 100644 --- a/spectator-reg-atlas/src/test/java/com/netflix/spectator/atlas/impl/EvalPayloadTest.java +++ b/spectator-reg-atlas/src/test/java/com/netflix/spectator/atlas/impl/EvalPayloadTest.java @@ -77,7 +77,7 @@ private List messages(int n) { @Test public void toBatchesBelowThreshold() { EvalPayload payload = new EvalPayload(0L, metrics(4)); - List batches = payload.toBatches(4); + List batches = payload.consumeBatches(4); Assertions.assertEquals(1, batches.size()); Assertions.assertSame(payload, batches.get(0)); } @@ -85,7 +85,7 @@ public void toBatchesBelowThreshold() { @Test public void toBatchesAboveThreshold() { EvalPayload payload = new EvalPayload(0L, metrics(21)); - List batches = payload.toBatches(4); + List batches = payload.consumeBatches(4); Assertions.assertEquals(6, batches.size()); int i = 0; for (EvalPayload batch : batches) { @@ -100,7 +100,7 @@ public void toBatchesAboveThreshold() { @Test public void toBatchesWithMessages() { EvalPayload payload = new EvalPayload(0L, metrics(21), messages(2)); - List batches = payload.toBatches(4); + List batches = payload.consumeBatches(4); Assertions.assertEquals(6, batches.size()); int i = 0; for (EvalPayload batch : batches) {