diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-11-05 18:08:45 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-11-05 18:08:45 +0100 |
commit | f97d62bd04bbad80faaa0589831642bcca489075 (patch) | |
tree | 84fa3fd542bcbdb54514ae418915a2217d63431f /statistics | |
parent | b4d75eb34c424d1f5e2b9b57a43be51a9c8e19b9 (diff) |
No need to log metrics anymore.
Diffstat (limited to 'statistics')
4 files changed, 6 insertions, 126 deletions
diff --git a/statistics/src/main/java/com/yahoo/statistics/Counter.java b/statistics/src/main/java/com/yahoo/statistics/Counter.java index f4b477636aa..0243fb4a024 100644 --- a/statistics/src/main/java/com/yahoo/statistics/Counter.java +++ b/statistics/src/main/java/com/yahoo/statistics/Counter.java @@ -165,16 +165,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); } |