mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
applying code changes for end of session reporting to new main
This commit is contained in:
parent
2f34a6e44d
commit
86f0a0298c
@ -80,7 +80,7 @@ public class NBSession extends NBBaseComponent implements Function<List<Cmd>, Ex
|
|||||||
registerNetworkInterfaceMetrics();
|
registerNetworkInterfaceMetrics();
|
||||||
registerCpuStatMetrics();
|
registerCpuStatMetrics();
|
||||||
clientMetricChecker.start();
|
clientMetricChecker.start();
|
||||||
|
bufferOrphanedMetrics = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public class NBSession extends NBBaseComponent implements Function<List<Cmd>, Ex
|
|||||||
ctx.controller().awaitCompletion(Long.MAX_VALUE);
|
ctx.controller().awaitCompletion(Long.MAX_VALUE);
|
||||||
logger.debug("completed");
|
logger.debug("completed");
|
||||||
}
|
}
|
||||||
|
metricsBuffer.printMetricSummary(this);
|
||||||
return collector.toExecutionResult();
|
return collector.toExecutionResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@ public class NBBaseComponent extends NBBaseComponentMetrics implements NBCompone
|
|||||||
protected final NBComponent parent;
|
protected final NBComponent parent;
|
||||||
protected final NBLabels labels;
|
protected final NBLabels labels;
|
||||||
private final List<NBComponent> children = new ArrayList<>();
|
private final List<NBComponent> children = new ArrayList<>();
|
||||||
|
protected NBMetricsBuffer metricsBuffer = new NBMetricsBuffer();
|
||||||
|
protected boolean bufferOrphanedMetrics = false;
|
||||||
|
|
||||||
public NBBaseComponent(NBComponent parentComponent) {
|
public NBBaseComponent(NBComponent parentComponent) {
|
||||||
this(parentComponent, NBLabels.forKV());
|
this(parentComponent, NBLabels.forKV());
|
||||||
@ -193,4 +195,20 @@ public class NBBaseComponent extends NBBaseComponentMetrics implements NBCompone
|
|||||||
return getLabels().asMap();
|
return getLabels().asMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called by the engine to report a component going out of scope. The metrics for that component
|
||||||
|
* will bubble up through the component layers and can be buffered for reporting at multiple levels.
|
||||||
|
*
|
||||||
|
* @param m The metric to report
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void reportExecutionMetric(NBMetric m) {
|
||||||
|
if (bufferOrphanedMetrics) {
|
||||||
|
metricsBuffer.addSummaryMetric(m);
|
||||||
|
}
|
||||||
|
if (parent != null) {
|
||||||
|
parent.reportExecutionMetric(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package io.nosqlbench.nb.api.components;
|
package io.nosqlbench.nb.api.components;
|
||||||
|
|
||||||
import io.nosqlbench.nb.api.components.decorators.NBProviderSearch;
|
import io.nosqlbench.nb.api.components.decorators.NBProviderSearch;
|
||||||
|
import io.nosqlbench.nb.api.engine.metrics.instruments.NBMetric;
|
||||||
import io.nosqlbench.nb.api.labels.NBLabeledElement;
|
import io.nosqlbench.nb.api.labels.NBLabeledElement;
|
||||||
import io.nosqlbench.nb.api.labels.NBLabels;
|
import io.nosqlbench.nb.api.labels.NBLabels;
|
||||||
|
|
||||||
@ -59,4 +60,6 @@ public interface NBComponent extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void close() throws RuntimeException;
|
void close() throws RuntimeException;
|
||||||
|
|
||||||
|
void reportExecutionMetric(NBMetric m);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package io.nosqlbench.nb.api.components;
|
package io.nosqlbench.nb.api.components;
|
||||||
|
|
||||||
|
import io.nosqlbench.nb.api.components.events.ComponentOutOfScope;
|
||||||
import io.nosqlbench.nb.api.config.standard.TestComponent;
|
import io.nosqlbench.nb.api.config.standard.TestComponent;
|
||||||
|
|
||||||
public class NBComponentExecutionScope implements AutoCloseable {
|
public class NBComponentExecutionScope implements AutoCloseable {
|
||||||
@ -29,6 +30,7 @@ public class NBComponentExecutionScope implements AutoCloseable {
|
|||||||
public void close() throws RuntimeException {
|
public void close() throws RuntimeException {
|
||||||
for (NBComponent component : components) {
|
for (NBComponent component : components) {
|
||||||
component.beforeDetach();
|
component.beforeDetach();
|
||||||
|
component.onEvent(new ComponentOutOfScope(component));
|
||||||
NBComponent parent = component.getParent();
|
NBComponent parent = component.getParent();
|
||||||
if (parent!=null) {
|
if (parent!=null) {
|
||||||
parent.detachChild(component);
|
parent.detachChild(component);
|
||||||
|
@ -25,6 +25,7 @@ import io.nosqlbench.nb.api.engine.metrics.reporters.*;
|
|||||||
import io.nosqlbench.nb.api.histo.HdrHistoLog;
|
import io.nosqlbench.nb.api.histo.HdrHistoLog;
|
||||||
import io.nosqlbench.nb.api.histo.HistoStats;
|
import io.nosqlbench.nb.api.histo.HistoStats;
|
||||||
import io.nosqlbench.nb.api.http.HttpPlugin;
|
import io.nosqlbench.nb.api.http.HttpPlugin;
|
||||||
|
import io.nosqlbench.nb.api.labels.MapLabels;
|
||||||
import io.nosqlbench.nb.api.optimizers.BobyqaOptimizerInstance;
|
import io.nosqlbench.nb.api.optimizers.BobyqaOptimizerInstance;
|
||||||
import io.nosqlbench.nb.api.files.FileAccess;
|
import io.nosqlbench.nb.api.files.FileAccess;
|
||||||
import io.nosqlbench.nb.api.labels.NBLabels;
|
import io.nosqlbench.nb.api.labels.NBLabels;
|
||||||
@ -308,7 +309,7 @@ public class NBCreators {
|
|||||||
public static class ConsoleReporterBuilder {
|
public static class ConsoleReporterBuilder {
|
||||||
private final NBComponent component;
|
private final NBComponent component;
|
||||||
private final PrintStream output;
|
private final PrintStream output;
|
||||||
private NBLabels labels = null;
|
private NBLabels labels = new MapLabels(Map.of());
|
||||||
private long interval = 1000;
|
private long interval = 1000;
|
||||||
private boolean oneLastTime = false;
|
private boolean oneLastTime = false;
|
||||||
private Set<MetricAttribute> disabledMetricAttributes = Set.of();
|
private Set<MetricAttribute> disabledMetricAttributes = Set.of();
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023 nosqlbench
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.nosqlbench.nb.api.components;
|
||||||
|
|
||||||
|
import io.nosqlbench.nb.api.engine.metrics.instruments.NBMetric;
|
||||||
|
import io.nosqlbench.nb.api.engine.metrics.reporters.ConsoleReporter;
|
||||||
|
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class NBMetricsBuffer {
|
||||||
|
private List<NBMetric> summaryMetrics = new ArrayList<>();
|
||||||
|
private PrintStream out = System.out;
|
||||||
|
|
||||||
|
public void setPrintStream(PrintStream out) {
|
||||||
|
this.out = out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<NBMetric> getSummaryMetrics() {
|
||||||
|
return summaryMetrics;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSummaryMetrics(List<NBMetric> summaryMetrics) {
|
||||||
|
this.summaryMetrics = summaryMetrics;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSummaryMetric(NBMetric metric) {
|
||||||
|
this.summaryMetrics.add(metric);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearSummaryMetrics() {
|
||||||
|
this.summaryMetrics.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printMetricSummary(NBComponent caller) {
|
||||||
|
try(ConsoleReporter summaryReporter = new NBCreators.ConsoleReporterBuilder(caller, this.out).build()) {
|
||||||
|
summaryReporter.reportOnce(summaryMetrics);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023 nosqlbench
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.nosqlbench.nb.api.components.events;
|
||||||
|
|
||||||
|
import io.nosqlbench.nb.api.components.NBComponent;
|
||||||
|
|
||||||
|
public class ComponentOutOfScope implements NBEvent {
|
||||||
|
private final NBComponent component;
|
||||||
|
|
||||||
|
public ComponentOutOfScope(NBComponent component) {
|
||||||
|
this.component = component;
|
||||||
|
}
|
||||||
|
}
|
@ -220,4 +220,26 @@ public class ConsoleReporter extends PeriodicTaskComponent {
|
|||||||
protected double convertDuration(double duration) {
|
protected double convertDuration(double duration) {
|
||||||
return duration / durationFactor;
|
return duration / durationFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reportOnce(List<NBMetric> summaryMetrics) {
|
||||||
|
List<NBMetricGauge> gauges = new ArrayList<>();
|
||||||
|
List<NBMetricCounter> counters = new ArrayList<>();
|
||||||
|
List<NBMetricHistogram> histograms = new ArrayList<>();
|
||||||
|
List<NBMetricMeter> meters = new ArrayList<>();
|
||||||
|
List<NBMetricTimer> timers = new ArrayList<>();
|
||||||
|
for (NBMetric metric : summaryMetrics) {
|
||||||
|
if (metric instanceof NBMetricGauge) {
|
||||||
|
gauges.add((NBMetricGauge) metric);
|
||||||
|
} if (metric instanceof NBMetricCounter) {
|
||||||
|
counters.add((NBMetricCounter) metric);
|
||||||
|
} if (metric instanceof NBMetricHistogram) {
|
||||||
|
histograms.add((NBMetricHistogram) metric);
|
||||||
|
} if (metric instanceof NBMetricMeter) {
|
||||||
|
meters.add((NBMetricMeter) metric);
|
||||||
|
} if (metric instanceof NBMetricTimer) {
|
||||||
|
timers.add((NBMetricTimer) metric);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
report(gauges, counters, histograms, meters, timers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user