Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Stop emit default value for counter TotalError and ReaderRestartProcessing #578

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ public static void main(String[] args) {
(MetricsConfiguration.CONFIG_MAP.get(StatsCollector.class).samplingInterval) / 2,
TimeUnit.MILLISECONDS);
METRIC_COLLECTOR_EXECUTOR.addScheduledMetricCollector(StatsCollector.instance());
StatsCollector.instance()
.addDefaultExceptionCode(StatExceptionCode.READER_RESTART_PROCESSING);
METRIC_COLLECTOR_EXECUTOR.setEnabled(true);
METRIC_COLLECTOR_EXECUTOR.start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand All @@ -52,6 +53,12 @@ public class StatsCollector extends PerformanceAnalyzerMetricsCollector {
private Map<String, AtomicInteger> counters = new ConcurrentHashMap<>();
private Date objectCreationTime = new Date();

private static final Map<String, String> DEFAULT_STATS_DATA = new HashMap<>();

static {
DEFAULT_STATS_DATA.put("MethodName", "CollectStatsMetric");
}

private List<StatExceptionCode> defaultExceptionCodes = new Vector<>();

public static StatsCollector instance() {
Expand Down Expand Up @@ -124,7 +131,6 @@ public StatsCollector(String name, int samplingIntervalMillis, Map<String, Strin
super(samplingIntervalMillis, name);
this.metadata = metadata;
addRcaVersionMetadata(this.metadata);
defaultExceptionCodes.add(StatExceptionCode.TOTAL_ERROR);
}

private StatsCollector(Map<String, String> metadata) {
Expand All @@ -150,7 +156,7 @@ public void collectMetrics(long startTime) {
}

writeStats(
metadata, currentCounters, null, null, objectCreationTime.getTime(), new Date().getTime());
metadata, currentCounters, DEFAULT_STATS_DATA, null, objectCreationTime.getTime(), new Date().getTime());
collectAndWriteRcaStats();
objectCreationTime = new Date();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ public void testMain() {
PerformanceAnalyzerApp.main(new String[0]);
Assert.assertFalse(ConfigStatus.INSTANCE.haveValidConfig());
Assert.assertEquals(StatsCollector.instance().getCounters().get("ReaderThreadStopped").get(), 1);
Assert.assertEquals(StatsCollector.instance().getCounters().get("TotalError").get(), 1);
Assert.assertFalse(StatsCollector.instance().getCounters().containsKey("ReaderRestartProcessing"));
}
}
}