enhance console reporter

This commit is contained in:
Jonathan Shook 2023-12-09 17:17:08 -06:00
parent 725a9b5d88
commit 16e3e587aa
2 changed files with 18 additions and 4 deletions

View File

@ -413,6 +413,11 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
), ),
sessionName sessionName
); );
// TODO: Decide whether this should be part of ctor consistency
Map.of(
"summary", options.getReportSummaryTo(),
"logsdir", options.getLogsDirectory().toString()
).forEach(session::setComponentProp);
options.wantsReportCsvTo().ifPresent(cfg -> { options.wantsReportCsvTo().ifPresent(cfg -> {
MetricInstanceFilter filter = new MetricInstanceFilter(); MetricInstanceFilter filter = new MetricInstanceFilter();
@ -439,7 +444,8 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
ExecutionResult sessionResult = session.apply(options.getCommands()); ExecutionResult sessionResult = session.apply(options.getCommands());
sessionResult.printSummary(System.out); // sessionResult.printSummary(System.out);
logger.info(sessionResult);
return sessionResult.getStatus().code; return sessionResult.getStatus().code;
} }

View File

@ -41,9 +41,10 @@ public class ConsoleReporter extends PeriodicTaskComponent {
private final long rateFactor; private final long rateFactor;
private final String durationUnit = TimeUnit.NANOSECONDS.toString().toLowerCase(Locale.US); private final String durationUnit = TimeUnit.NANOSECONDS.toString().toLowerCase(Locale.US);
private final long durationFactor = TimeUnit.NANOSECONDS.toNanos(1); private final long durationFactor = TimeUnit.NANOSECONDS.toNanos(1);
public ConsoleReporter(NBComponent node, NBLabels extraLabels, long millis, boolean oneLastTime, public ConsoleReporter(NBComponent node, NBLabels extraLabels, long millis, boolean oneLastTime,
PrintStream output, Set<MetricAttribute> disabledMetricAttributes) { PrintStream output, Set<MetricAttribute> disabledMetricAttributes) {
super(node, extraLabels, millis, oneLastTime,"REPORT-CONSOLE"); super(node, extraLabels, millis, oneLastTime, "REPORT-CONSOLE");
this.output = output; this.output = output;
this.dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, this.dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT,
DateFormat.MEDIUM, DateFormat.MEDIUM,
@ -190,8 +191,10 @@ public class ConsoleReporter extends PeriodicTaskComponent {
/** /**
* Print only if the attribute is enabled * Print only if the attribute is enabled
* *
* @param type Metric attribute * @param type
* @param status Status to be logged * Metric attribute
* @param status
* Status to be logged
*/ */
private void printIfEnabled(MetricAttribute type, String status) { private void printIfEnabled(MetricAttribute type, String status) {
if (getDisabledMetricAttributes().contains(type)) { if (getDisabledMetricAttributes().contains(type)) {
@ -242,4 +245,9 @@ public class ConsoleReporter extends PeriodicTaskComponent {
} }
report(gauges, counters, histograms, meters, timers); report(gauges, counters, histograms, meters, timers);
} }
public void reportCountsOnce(List<NBMetric> summaryMetrics) {
// TODO: implement counts only renderer
// TODO: resolve ambiguity around reporting counts only or reporting nothing for short sessions
}
} }