summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2021-11-05 22:27:21 +0100
committerGitHub <noreply@github.com>2021-11-05 22:27:21 +0100
commita5ccb0a496677a9638510b12f741de465455d2ba (patch)
treed55ad6f0a33fa3e14f36a9c83146ae367a422a0f
parentfdbbd58335d7df5b9ad8e1ba81d62f92ee9d3bf9 (diff)
parent8b100501faa14a595425c43e9d653e1e89f7b160 (diff)
Merge pull request #19890 from vespa-engine/balder/log-is-not-used-for-metrics-anymore
No need to log metrics anymore.
-rw-r--r--container-search/abi-spec.json1
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/statistics/StatisticsSearcher.java47
-rw-r--r--container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java106
-rw-r--r--statistics/src/main/java/com/yahoo/statistics/Counter.java10
-rw-r--r--statistics/src/main/java/com/yahoo/statistics/Handle.java2
-rw-r--r--statistics/src/main/java/com/yahoo/statistics/Value.java89
-rw-r--r--statistics/src/test/java/com/yahoo/statistics/ValueTestCase.java33
7 files changed, 47 insertions, 241 deletions
diff --git a/container-search/abi-spec.json b/container-search/abi-spec.json
index 9d3b4934aa3..183bb33b4f4 100644
--- a/container-search/abi-spec.json
+++ b/container-search/abi-spec.json
@@ -4322,6 +4322,7 @@
"public"
],
"methods": [
+ "public void <init>(com.yahoo.jdisc.Metric, com.yahoo.container.handler.threadpool.ContainerThreadPool, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.language.process.Embedder, com.yahoo.search.searchchain.ExecutionFactory)",
"public void <init>(com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric, com.yahoo.container.handler.threadpool.ContainerThreadPool, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.language.process.Embedder, com.yahoo.search.searchchain.ExecutionFactory)",
"public void <init>(com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric, com.yahoo.container.handler.threadpool.ContainerThreadPool, com.yahoo.container.logging.AccessLog, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.search.searchchain.ExecutionFactory)",
"public void <init>(com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric, java.util.concurrent.Executor, com.yahoo.container.logging.AccessLog, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.search.searchchain.ExecutionFactory)",
diff --git a/container-search/src/main/java/com/yahoo/prelude/statistics/StatisticsSearcher.java b/container-search/src/main/java/com/yahoo/prelude/statistics/StatisticsSearcher.java
index 63704788b20..1d1c446f6e1 100644
--- a/container-search/src/main/java/com/yahoo/prelude/statistics/StatisticsSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/statistics/StatisticsSearcher.java
@@ -3,7 +3,6 @@ package com.yahoo.prelude.statistics;
import com.yahoo.component.chain.dependencies.Before;
import com.yahoo.concurrent.CopyOnWriteHashMap;
-import com.yahoo.container.protect.Error;
import com.yahoo.jdisc.Metric;
import com.yahoo.jdisc.http.HttpRequest;
import com.yahoo.metrics.simple.MetricReceiver;
@@ -19,8 +18,6 @@ import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.PhaseNames;
-import com.yahoo.statistics.Counter;
-import com.yahoo.statistics.Value;
import java.util.HashMap;
import java.util.Map;
@@ -76,19 +73,7 @@ public class StatisticsSearcher extends Searcher {
private static final String RELEVANCE_AT_3_METRIC = "relevance.at_3";
private static final String RELEVANCE_AT_10_METRIC = "relevance.at_10";
- private final Counter queriesCounter; // basic counter
- private final Counter failedQueriesCounter; // basic counter
- private final Counter nullQueriesCounter; // basic counter
- private final Counter illegalQueriesCounter; // basic counter
- private final Value meanQueryLatency; // mean pr 5 min
- private final Value queryLatencyBuckets;
- private final Value maxQueryLatency; // separate to avoid name mangling
@SuppressWarnings("unused") // all the work is done by the callback
- private final Value peakQPS; // peak 1s QPS
- private final Counter emptyResultsCounter; // number of results containing no concrete hits
- private final Value hitsPerQuery; // mean number of hits per query
- private final Value totalHitsPerQuery;
-
private final PeakQpsReporter peakQpsReporter;
// Naming of enums are reflected directly in metric dimensions and should not be changed as they are public API
@@ -123,7 +108,6 @@ public class StatisticsSearcher extends Searcher {
private void flushPeakQps(long now) {
double ms = (double) (now - prevMaxQPSTime);
final double value = ((double)queriesForQPS) / (ms / 1000.0);
- peakQPS.put(value);
metric.set(PEAK_QPS_METRIC, value, metricContext);
prevMaxQPSTime = now;
queriesForQPS = 0;
@@ -135,22 +119,10 @@ public class StatisticsSearcher extends Searcher {
}
}
- public StatisticsSearcher(com.yahoo.statistics.Statistics manager, Metric metric, MetricReceiver metricReceiver) {
+ public StatisticsSearcher(Metric metric, MetricReceiver metricReceiver) {
this.peakQpsReporter = new PeakQpsReporter();
this.metric = metric;
- queriesCounter = new Counter(QUERIES_METRIC, manager, false);
- failedQueriesCounter = new Counter(FAILED_QUERIES_METRIC, manager, false);
- nullQueriesCounter = new Counter("null_queries", manager, false);
- illegalQueriesCounter = new Counter("illegal_queries", manager, false);
- meanQueryLatency = new Value(MEAN_QUERY_LATENCY_METRIC, manager, new Value.Parameters().setLogRaw(false).setLogMean(true).setNameExtension(false));
- maxQueryLatency = new Value(MAX_QUERY_LATENCY_METRIC, manager, new Value.Parameters().setLogRaw(false).setLogMax(true).setNameExtension(false));
- queryLatencyBuckets = Value.buildValue(QUERY_LATENCY_METRIC, manager, null);
- peakQPS = new Value(PEAK_QPS_METRIC, manager, new Value.Parameters().setLogRaw(false).setLogMax(true).setNameExtension(false));
- hitsPerQuery = new Value(HITS_PER_QUERY_METRIC, manager, new Value.Parameters().setLogRaw(false).setLogMean(true).setNameExtension(false));
- totalHitsPerQuery = new Value(TOTALHITS_PER_QUERY_METRIC, manager, new Value.Parameters().setLogRaw(false).setLogMean(true).setNameExtension(false));
-
- emptyResultsCounter = new Counter(EMPTY_RESULTS_METRIC, manager, false);
metricReceiver.declareGauge(QUERY_LATENCY_METRIC, Optional.empty(), new MetricSettings.Builder().histogram(true).build());
metricReceiver.declareGauge(HITS_PER_QUERY_METRIC, Optional.empty(), new MetricSettings.Builder().histogram(true).build());
metricReceiver.declareGauge(TOTALHITS_PER_QUERY_METRIC, Optional.empty(), new MetricSettings.Builder().histogram(true).build());
@@ -265,7 +237,7 @@ public class StatisticsSearcher extends Searcher {
} else {
getLogger().log(Level.WARNING,
"Apparently negative latency measure, start: " + start_ns
- + ", end: " + end_ns + ", for query: " + query.toString());
+ + ", end: " + end_ns + ", for query: " + query);
}
if (result.hits().getError() != null) {
incrErrorCount(result, metricContext);
@@ -281,16 +253,12 @@ public class StatisticsSearcher extends Searcher {
metric.add(DOCS_TOTAL_METRIC, queryCoverage.getActive(), metricContext);
}
int hitCount = result.getConcreteHitCount();
- hitsPerQuery.put(hitCount);
metric.set(HITS_PER_QUERY_METRIC, (double) hitCount, metricContext);
long totalHitCount = result.getTotalHitCount();
- totalHitsPerQuery.put(totalHitCount);
metric.set(TOTALHITS_PER_QUERY_METRIC, (double) totalHitCount, metricContext);
-
metric.set(QUERY_HIT_OFFSET_METRIC, (double) (query.getHits() + query.getOffset()), metricContext);
if (hitCount == 0) {
- emptyResultsCounter.increment();
metric.add(EMPTY_RESULTS_METRIC, 1, metricContext);
}
@@ -309,31 +277,20 @@ public class StatisticsSearcher extends Searcher {
private void addLatency(long latency_ns, Metric.Context metricContext) {
double latency = 0.000001 * latency_ns;
- //myStats.addLatency(latency);
- meanQueryLatency.put(latency);
metric.set(QUERY_LATENCY_METRIC, latency, metricContext);
metric.set(MEAN_QUERY_LATENCY_METRIC, latency, metricContext);
- maxQueryLatency.put(latency);
metric.set(MAX_QUERY_LATENCY_METRIC, latency, metricContext);
- queryLatencyBuckets.put(latency);
}
private void incrQueryCount(Metric.Context metricContext) {
- //myStats.incrQueryCnt();
- queriesCounter.increment();
metric.add(QUERIES_METRIC, 1, metricContext);
}
private void incrErrorCount(Result result, Metric.Context metricContext) {
- failedQueriesCounter.increment();
metric.add(FAILED_QUERIES_METRIC, 1, metricContext);
if (result == null) // the chain threw an exception
metric.add("error.unhandled_exception", 1, metricContext);
- else if (result.hits().getErrorHit().hasOnlyErrorCode(Error.NULL_QUERY.code))
- nullQueriesCounter.increment();
- else if (result.hits().getErrorHit().hasOnlyErrorCode(Error.ILLEGAL_QUERY.code))
- illegalQueriesCounter.increment();
}
/**
diff --git a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java
index a38dd5dc67a..52a3672e7a2 100644
--- a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java
+++ b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java
@@ -49,10 +49,7 @@ import com.yahoo.search.statistics.ElapsedTime;
import com.yahoo.slime.Inspector;
import com.yahoo.slime.ObjectTraverser;
import com.yahoo.slime.SlimeUtils;
-import com.yahoo.statistics.Callback;
-import com.yahoo.statistics.Handle;
import com.yahoo.statistics.Statistics;
-import com.yahoo.statistics.Value;
import com.yahoo.vespa.configdefinition.SpecialtokensConfig;
import com.yahoo.yolean.Exceptions;
import com.yahoo.yolean.trace.TraceNode;
@@ -93,9 +90,6 @@ public class SearchHandler extends LoggingRequestHandler {
static final String RENDERER_DIMENSION = "renderer";
private static final String JSON_CONTENT_TYPE = "application/json";
-
- private final Value searchConnections;
-
public static final String defaultSearchChainName = "default";
private static final String fallbackSearchChain = "vespa";
@@ -105,30 +99,26 @@ public class SearchHandler extends LoggingRequestHandler {
private final Optional<String> hostResponseHeaderKey;
private final String selfHostname = HostName.getLocalhost();
-
private final Embedder embedder;
-
private final ExecutionFactory executionFactory;
-
private final AtomicLong numRequestsLeftToTrace;
private final static RequestHandlerSpec REQUEST_HANDLER_SPEC = RequestHandlerSpec.builder()
.withAclMapping(SearchHandler.aclRequestMapper()).build();
- private final class MeanConnections implements Callback {
-
- @Override
- public void run(Handle h, boolean firstTime) {
- if (firstTime) {
- metric.set(SEARCH_CONNECTIONS, 0.0d, null);
- return;
- }
- Value v = (Value) h;
- metric.set(SEARCH_CONNECTIONS, v.getMean(), null);
- }
+ @Inject
+ public SearchHandler(Metric metric,
+ ContainerThreadPool threadpool,
+ CompiledQueryProfileRegistry queryProfileRegistry,
+ ContainerHttpConfig config,
+ Embedder embedder,
+ ExecutionFactory executionFactory) {
+ this(metric, threadpool.executor(), queryProfileRegistry, embedder, executionFactory,
+ config.numQueriesToTraceOnDebugAfterConstruction(),
+ config.hostResponseHeaderKey().equals("") ? Optional.empty() : Optional.of(config.hostResponseHeaderKey()));
}
- @Inject
+ @Deprecated
public SearchHandler(Statistics statistics,
Metric metric,
ContainerThreadPool threadpool,
@@ -136,7 +126,7 @@ public class SearchHandler extends LoggingRequestHandler {
ContainerHttpConfig config,
Embedder embedder,
ExecutionFactory executionFactory) {
- this(statistics, metric, threadpool.executor(), queryProfileRegistry, embedder, executionFactory,
+ this(metric, threadpool.executor(), queryProfileRegistry, embedder, executionFactory,
config.numQueriesToTraceOnDebugAfterConstruction(),
config.hostResponseHeaderKey().equals("") ? Optional.empty() : Optional.of(config.hostResponseHeaderKey()));
}
@@ -166,12 +156,7 @@ public class SearchHandler extends LoggingRequestHandler {
CompiledQueryProfileRegistry queryProfileRegistry,
ContainerHttpConfig containerHttpConfig,
ExecutionFactory executionFactory) {
- this(statistics,
- metric,
- executor,
- queryProfileRegistry,
- Embedder.throwsOnUse,
- executionFactory,
+ this(metric, executor, queryProfileRegistry, Embedder.throwsOnUse, executionFactory,
containerHttpConfig.numQueriesToTraceOnDebugAfterConstruction(),
containerHttpConfig.hostResponseHeaderKey().equals("") ?
Optional.empty() : Optional.of(containerHttpConfig.hostResponseHeaderKey()));
@@ -188,12 +173,8 @@ public class SearchHandler extends LoggingRequestHandler {
QueryProfilesConfig queryProfileConfig,
ContainerHttpConfig containerHttpConfig,
ExecutionFactory executionFactory) {
- this(statistics,
- metric,
- executor,
- QueryProfileConfigurer.createFromConfig(queryProfileConfig).compile(),
- Embedder.throwsOnUse,
- executionFactory,
+ this(metric, executor, QueryProfileConfigurer.createFromConfig(queryProfileConfig).compile(),
+ Embedder.throwsOnUse, executionFactory,
containerHttpConfig.numQueriesToTraceOnDebugAfterConstruction(),
containerHttpConfig.hostResponseHeaderKey().equals("") ?
Optional.empty() : Optional.of( containerHttpConfig.hostResponseHeaderKey()));
@@ -210,12 +191,11 @@ public class SearchHandler extends LoggingRequestHandler {
CompiledQueryProfileRegistry queryProfileRegistry,
ExecutionFactory executionFactory,
Optional<String> hostResponseHeaderKey) {
- this(statistics, metric, executor, queryProfileRegistry, Embedder.throwsOnUse,
+ this(metric, executor, queryProfileRegistry, Embedder.throwsOnUse,
executionFactory, 0, hostResponseHeaderKey);
}
- private SearchHandler(Statistics statistics,
- Metric metric,
+ private SearchHandler(Metric metric,
Executor executor,
CompiledQueryProfileRegistry queryProfileRegistry,
Embedder embedder,
@@ -230,14 +210,9 @@ public class SearchHandler extends LoggingRequestHandler {
this.maxThreads = examineExecutor(executor);
- searchConnections = new Value(SEARCH_CONNECTIONS, statistics,
- new Value.Parameters().setLogRaw(true).setLogMax(true)
- .setLogMean(true).setLogMin(true)
- .setNameExtension(true)
- .setCallback(new MeanConnections()));
-
this.hostResponseHeaderKey = hostResponseHeaderKey;
this.numRequestsLeftToTrace = new AtomicLong(numQueriesToTraceOnDebugAfterStartup);
+ metric.set(SEARCH_CONNECTIONS, 0.0d, null);
}
/** @deprecated use the other constructor */
@@ -487,13 +462,8 @@ public class SearchHandler extends LoggingRequestHandler {
query.trace("Invoking " + searchChain, false, 2);
}
- if (searchConnections != null) {
- connectionStatistics();
- } else {
- log.log(Level.WARNING,
- "searchConnections is a null reference, probably a known race condition during startup.",
- new IllegalStateException("searchConnections reference is null."));
- }
+ connectionStatistics();
+
try {
return searchAndFill(query, searchChain);
} catch (ParseException e) {
@@ -525,24 +495,24 @@ public class SearchHandler extends LoggingRequestHandler {
}
private void connectionStatistics() {
+ if (maxThreads <= 3) return;
+
int connections = requestsInFlight.intValue();
- searchConnections.put(connections);
- if (maxThreads > 3) {
- // cast to long to avoid overflows if maxThreads is at no
- // log value (maxint)
- long maxThreadsAsLong = maxThreads;
- long connectionsAsLong = connections;
- // only log when exactly crossing the limit to avoid
- // spamming the log
- if (connectionsAsLong < maxThreadsAsLong * 9L / 10L) {
- // NOP
- } else if (connectionsAsLong == maxThreadsAsLong * 9L / 10L) {
- log.log(Level.WARNING, threadConsumptionMessage(connections, maxThreads, "90"));
- } else if (connectionsAsLong == maxThreadsAsLong * 95L / 100L) {
- log.log(Level.WARNING, threadConsumptionMessage(connections, maxThreads, "95"));
- } else if (connectionsAsLong == maxThreadsAsLong) {
- log.log(Level.WARNING, threadConsumptionMessage(connections, maxThreads, "100"));
- }
+ metric.set(SEARCH_CONNECTIONS, connections, null);
+ // cast to long to avoid overflows if maxThreads is at no
+ // log value (maxint)
+ long maxThreadsAsLong = maxThreads;
+ long connectionsAsLong = connections;
+ // only log when exactly crossing the limit to avoid
+ // spamming the log
+ if (connectionsAsLong < maxThreadsAsLong * 9L / 10L) {
+ // NOP
+ } else if (connectionsAsLong == maxThreadsAsLong * 9L / 10L) {
+ log.log(Level.WARNING, threadConsumptionMessage(connections, maxThreads, "90"));
+ } else if (connectionsAsLong == maxThreadsAsLong * 95L / 100L) {
+ log.log(Level.WARNING, threadConsumptionMessage(connections, maxThreads, "95"));
+ } else if (connectionsAsLong == maxThreadsAsLong) {
+ log.log(Level.WARNING, threadConsumptionMessage(connections, maxThreads, "100"));
}
}
@@ -598,7 +568,7 @@ public class SearchHandler extends LoggingRequestHandler {
}
private void traceVespaVersion(Query query) {
- query.trace("Vespa version: " + Vtag.currentVersion.toString(), false, 4);
+ query.trace("Vespa version: " + Vtag.currentVersion, false, 4);
}
public SearchChainRegistry getSearchChainRegistry() { return executionFactory.searchChainRegistry();
diff --git a/statistics/src/main/java/com/yahoo/statistics/Counter.java b/statistics/src/main/java/com/yahoo/statistics/Counter.java
index f4b477636aa..2e39cfa6e70 100644
--- a/statistics/src/main/java/com/yahoo/statistics/Counter.java
+++ b/statistics/src/main/java/com/yahoo/statistics/Counter.java
@@ -1,10 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.statistics;
-
import java.util.concurrent.atomic.AtomicLong;
-import com.yahoo.log.event.Event;
import com.yahoo.container.StatisticsConfig;
@@ -165,16 +163,10 @@ public class Counter extends Handle {
*/
@Override
public void runHandle() {
- String name = getName();
- long lastCurrent;
boolean resetState = getResetCounter();
if (resetState) {
- lastCurrent = current.getAndSet(0L);
- Event.value(name, lastCurrent);
- } else {
- lastCurrent = current.get();
- Event.count(name, lastCurrent);
+ current.set(0L);
}
}
diff --git a/statistics/src/main/java/com/yahoo/statistics/Handle.java b/statistics/src/main/java/com/yahoo/statistics/Handle.java
index 40491241137..f67dafa9309 100644
--- a/statistics/src/main/java/com/yahoo/statistics/Handle.java
+++ b/statistics/src/main/java/com/yahoo/statistics/Handle.java
@@ -1,10 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.statistics;
-
import java.util.TimerTask;
-
/**
* Base class for the interface to the statistics framework.
*
diff --git a/statistics/src/main/java/com/yahoo/statistics/Value.java b/statistics/src/main/java/com/yahoo/statistics/Value.java
index fa4b7db0da2..98446a10135 100644
--- a/statistics/src/main/java/com/yahoo/statistics/Value.java
+++ b/statistics/src/main/java/com/yahoo/statistics/Value.java
@@ -8,7 +8,6 @@ import java.util.logging.Logger;
import com.yahoo.container.StatisticsConfig;
import com.yahoo.container.StatisticsConfig.Values.Operations;
import java.util.logging.Level;
-import com.yahoo.log.event.Event;
import com.yahoo.statistics.SampleSet.Sampling;
/**
@@ -47,9 +46,7 @@ public class Value extends Handle {
private final boolean logHistogram;
private final Limits histogram;
- private final boolean nameExtension;
final HistogramType histogramId;
- private final char appendChar;
private static final Logger log = Logger.getLogger(Value.class.getName());
static final String HISTOGRAM_TYPE_WARNING = "Histogram types other than REGULAR currently not supported."
@@ -354,7 +351,6 @@ public class Value extends Handle {
this.logRaw = isTrue(parameters.logRaw);
this.logSum = isTrue(parameters.logSum);
this.logInsertions = isTrue(parameters.logInsertions);
- this.nameExtension = isTrue(parameters.nameExtension);
if (logHistogram) {
if (!parameters.limits.isFrozen()) {
throw new IllegalStateException("The Limits instance must be frozen.");
@@ -368,19 +364,14 @@ public class Value extends Handle {
this.histogram = null;
this.histogramId = HistogramType.REGULAR;
}
- Character appendChar = parameters.appendChar;
- if (appendChar == null) {
- this.appendChar = '.';
- } else {
- this.appendChar = appendChar.charValue();
- }
+
if (parameters.register) {
manager.register(this);
}
}
private static boolean isTrue(Boolean b) {
- return b != null && b.booleanValue();
+ return b != null && b;
}
/**
@@ -632,77 +623,7 @@ public class Value extends Handle {
*/
@Override
public void runHandle() {
- String rawImage = null;
- String meanImage = null;
- String minImage = null;
- String maxImage = null;
- String sumImage = null;
- String insertionsImage = null;
- String histImage = null;
- String lastHist = null;
- String histType = null;
- Snapshot now = getCurrentState();
-
- if (nameExtension) {
- if (logRaw) {
- rawImage = getName();
- }
- if (logMean) {
- meanImage = getName() + appendChar + "mean";
- }
- if (logMin) {
- minImage = getName() + appendChar + "min";
- }
- if (logMax) {
- maxImage = getName() + appendChar + "max";
- }
- if (logSum) {
- sumImage = getName() + appendChar + "sum";
- }
- if (logInsertions) {
- insertionsImage = getName() + appendChar + "insertions";
- }
- } else {
- if (logRaw) {
- rawImage = getName();
- } else if (logMean) {
- meanImage = getName();
- } else if (logMin) {
- minImage = getName();
- } else if (logMax) {
- maxImage = getName();
- } else if (logSum) {
- sumImage = getName();
- } else if (logInsertions) {
- insertionsImage = getName();
- }
- }
- if (logHistogram) {
- histImage = getName();
- lastHist = now.histogram.toString();
- histType = histogramId.toString();
- }
- if (rawImage != null) {
- Event.value(rawImage, now.raw);
- }
- if (meanImage != null) {
- Event.value(meanImage, now.mean);
- }
- if (minImage != null) {
- Event.value(minImage, now.min);
- }
- if (maxImage != null) {
- Event.value(maxImage, now.max);
- }
- if (histImage != null) {
- Event.histogram(histImage, lastHist, histType);
- }
- if (sumImage != null) {
- Event.value(sumImage, now.sum);
- }
- if (insertionsImage != null) {
- Event.value(insertionsImage, now.insertions);
- }
+ getAndSetCurrentState();
}
public String toString() {
@@ -772,7 +693,7 @@ public class Value extends Handle {
}
}
- private Snapshot getCurrentState() {
+ private Snapshot getAndSetCurrentState() {
double lastInsertions = 0L;
double lastMax = 0.0d;
double lastMin = 0.0d;
@@ -820,7 +741,7 @@ public class Value extends Handle {
ValueProxy getProxyAndReset() {
ValueProxy p = new ValueProxy(getName());
- Snapshot now = getCurrentState();
+ Snapshot now = getAndSetCurrentState();
if (logRaw) {
p.setRaw(now.raw);
diff --git a/statistics/src/test/java/com/yahoo/statistics/ValueTestCase.java b/statistics/src/test/java/com/yahoo/statistics/ValueTestCase.java
index a96d684b961..72825ffd6ad 100644
--- a/statistics/src/test/java/com/yahoo/statistics/ValueTestCase.java
+++ b/statistics/src/test/java/com/yahoo/statistics/ValueTestCase.java
@@ -190,7 +190,6 @@ public class ValueTestCase {
v.put(x);
assertEquals(x, v.getMean(), delta);
v.run();
- assertEquals(true, h.gotRecord);
logger.removeHandler(h);
logger.setUseParentHandlers(initUseParentHandlers);
}
@@ -219,38 +218,6 @@ public class ValueTestCase {
v.put(1.5d);
v.put(1.5d);
v.run();
- assertEquals(true, h.gotRecord);
- assertEquals(true, h.gotWarning);
- logger.removeHandler(h);
- logger.setUseParentHandlers(initUseParentHandlers);
- }
-
- @Test
- public void testCumulativeHistogram() {
- Logger logger = Logger.getLogger(Value.class.getName());
- boolean initUseParentHandlers = logger.getUseParentHandlers();
- logger.setUseParentHandlers(false);
- CheckHistogram h = new CheckHistogram("(0) < 0.0 (2) < 1.0 (2) < 2.0 (0)", "REGULAR");
- logger.addHandler(h);
- List<Operations.Arguments.Builder> histogram = Arrays.asList(new Operations.Arguments.Builder[] {
- new Operations.Arguments.Builder().key("limits").value("0, 1, 2")});
- List<Operations.Builder> ops = Arrays.asList(new Operations.Builder[] {
- new Operations.Builder().name(Operations.Name.Enum.CUMULATIVE).arguments(histogram) });
- StatisticsConfig c = new StatisticsConfig(
- new StatisticsConfig.Builder()
- .values(new StatisticsConfig.Values.Builder().name(
- NALLE).operations(ops)));
- MockStatistics m = new MockStatistics();
- m.config = c;
- Value v = Value.buildValue(NALLE, m, null);
- assertEquals(HistogramType.REGULAR.toString(), v.histogramId.toString());
- v.put(.5d);
- v.put(.5d);
- v.put(1.5d);
- v.put(1.5d);
- v.run();
- assertEquals(true, h.gotRecord);
- assertEquals(true, h.gotWarning);
logger.removeHandler(h);
logger.setUseParentHandlers(initUseParentHandlers);
}