Skip to content

Commit

Permalink
Fix ShardEvents and ShardBulkDocs null metrics (#283)
Browse files Browse the repository at this point in the history
* Fix ShardEvents and ShardBulkDocs null metrics

---------

Signed-off-by: Filip Drobnjakovic <[email protected]>
(cherry picked from commit 8f5d1f1)
  • Loading branch information
Tjofil authored and github-actions[bot] committed Jan 27, 2023
1 parent 6b9df73 commit 1e3d17f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public SelectHavingStep<Record> fetchLatency() {
this.add(DSL.field(DSL.name(Fields.SHARD_ROLE.toString()), String.class));
this.add(DSL.field(DSL.name(Fields.ST.toString()), Long.class));
this.add(DSL.field(DSL.name(Fields.ET.toString()), Long.class));
this.add(DSL.field(DSL.name(Fields.DOC_COUNT.toString()), Long.class));
this.add(DSL.field(DSL.name(Fields.DOC_COUNT.toString()), Double.class));
this.add(
DSL.field(Fields.ET.toString())
.minus(DSL.field(Fields.ST.toString()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
Expand Down Expand Up @@ -53,6 +54,42 @@ public void before() throws Exception {
rootLocation = "build/resources/test/reader/";
}

@Test
public void testShardBulkParseAndQuery() throws Exception {
deleteAll();
ReaderMetricsProcessor mp =
new ReaderMetricsProcessor(rootLocation, true, new AppContext());

mp.processMetrics(rootLocation, 1566413985000L);
mp.processMetrics(rootLocation, 1566413990000L);

Result<Record> res =
mp.getMetricsDB()
.getValue()
.queryMetric(
Arrays.asList("ShardEvents", "ShardBulkDocs"),
Arrays.asList("sum", "sum"),
Arrays.asList("Operation"));

boolean shardbulkEncountered = false;

for (Record record : res) {
if (PerformanceAnalyzerMetrics.sShardBulkPath.equals(record.get("Operation"))) {
assertNotNull(record.get("ShardEvents"));
assertNotNull(record.get("ShardBulkDocs"));
assertEquals(1519.0, (Double) record.get("ShardEvents"), 0.0);
assertEquals(507096.0, (Double) record.get("ShardBulkDocs"), 0.0);
shardbulkEncountered = true;
}
}

assertTrue(shardbulkEncountered);

mp.trimOldSnapshots();
mp.trimOldMetricsDBFiles();
mp.deleteDBs();
}

@Test
public void testReaderMetricsProcessorFrequently() throws Exception {
deleteAll();
Expand Down

0 comments on commit 1e3d17f

Please sign in to comment.