diff options
author | Arne Juul <arnej@yahoo-inc.com> | 2018-10-05 12:58:32 +0000 |
---|---|---|
committer | Arne Juul <arnej@yahoo-inc.com> | 2018-10-08 13:08:51 +0000 |
commit | b42a5ef01b030c673e9cfb0c32cbde9b459098fc (patch) | |
tree | e2f9fcc5041d60f7095dc0da69272bd540714f64 /metrics | |
parent | 3f8389d884735643878dac7b88d3e8c13ea43ea8 (diff) |
remove legacy tags, always pass vector
Diffstat (limited to 'metrics')
23 files changed, 122 insertions, 187 deletions
diff --git a/metrics/src/tests/countmetrictest.cpp b/metrics/src/tests/countmetrictest.cpp index 8ef551ead53..af94f78dfdf 100644 --- a/metrics/src/tests/countmetrictest.cpp +++ b/metrics/src/tests/countmetrictest.cpp @@ -20,7 +20,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(CountMetricTest); void CountMetricTest::testLongCountMetric() { - LongCountMetric m("test", "tag", "description"); + LongCountMetric m("test", {{"tag"}}, "description"); m.set(100); CPPUNIT_ASSERT_EQUAL(uint64_t(100), m.getValue()); m.inc(5); @@ -32,7 +32,7 @@ void CountMetricTest::testLongCountMetric() m.reset(); CPPUNIT_ASSERT_EQUAL(uint64_t(0), m.getValue()); - LongCountMetric n("m2", "", "desc"); + LongCountMetric n("m2", {}, "desc"); n.set(6); CPPUNIT_ASSERT_EQUAL(uint64_t(6), n.getValue()); diff --git a/metrics/src/tests/loadmetrictest.cpp b/metrics/src/tests/loadmetrictest.cpp index 2bdb47add3f..5cbec2c4fae 100644 --- a/metrics/src/tests/loadmetrictest.cpp +++ b/metrics/src/tests/loadmetrictest.cpp @@ -48,7 +48,7 @@ LoadMetricTest::testNormalUsage() LoadTypeSetImpl loadTypes; loadTypes.add(32, "foo").add(1000, "bar"); LoadMetric<LongValueMetric> metric( - loadTypes, LongValueMetric("put", "", "Put")); + loadTypes, LongValueMetric("put", {}, "Put")); } namespace { @@ -56,8 +56,8 @@ namespace { LongAverageMetric metric; MyMetricSet(MetricSet* owner = 0) - : MetricSet("tick", "", "", owner), - metric("tack", "", "", this) + : MetricSet("tick", {}, "", owner), + metric("tack", {}, "", this) { } MetricSet* clone(std::vector<Metric::UP> &ownerList, CopyType copyType, @@ -80,7 +80,7 @@ LoadMetricTest::testClone(Metric::CopyType copyType) { LoadTypeSetImpl loadTypes; loadTypes.add(32, "foo").add(1000, "bar"); - MetricSet top("top", "", ""); + MetricSet top("top", {}, ""); MyMetricSet myset; LoadMetric<MyMetricSet> metric(loadTypes, myset, &top); metric[loadTypes["foo"]].metric.addValue(5); @@ -110,7 +110,7 @@ LoadMetricTest::testAdding() { LoadTypeSetImpl loadTypes; loadTypes.add(32, "foo").add(1000, "bar"); - MetricSet top("top", "", ""); + MetricSet top("top", {}, ""); MyMetricSet myset; LoadMetric<MyMetricSet> metric(loadTypes, myset, &top); metric[loadTypes["foo"]].metric.addValue(5); diff --git a/metrics/src/tests/metric_timer_test.cpp b/metrics/src/tests/metric_timer_test.cpp index 0721f2202ac..0087da713b9 100644 --- a/metrics/src/tests/metric_timer_test.cpp +++ b/metrics/src/tests/metric_timer_test.cpp @@ -27,7 +27,7 @@ using namespace std::literals::chrono_literals; template <typename MetricType> void MetricTimerTest::do_test_metric_timer_for_metric_type() { MetricTimer timer; - MetricType metric("foo", "", ""); + MetricType metric("foo", {}, ""); std::this_thread::sleep_for(5ms); // Guaranteed to be monotonic time timer.stop(metric); // getDoubleValue() is present for both long and double metric types diff --git a/metrics/src/tests/metricmanagertest.cpp b/metrics/src/tests/metricmanagertest.cpp index 8424d3be3fe..b89dbad738b 100644 --- a/metrics/src/tests/metricmanagertest.cpp +++ b/metrics/src/tests/metricmanagertest.cpp @@ -68,10 +68,10 @@ struct SubMetricSet : public MetricSet SubMetricSet::SubMetricSet(const Metric::String & name, MetricSet* owner) - : MetricSet(name, "sub", "sub desc", owner), - val1("val1", "tag4 snaptest", "val1 desc", this), - val2("val2", "tag5", "val2 desc", this), - valsum("valsum", "tag4 snaptest", "valsum desc", this) + : MetricSet(name, {{"sub"}}, "sub desc", owner), + val1("val1", {{"tag4"},{"snaptest"}}, "val1 desc", this), + val2("val2", {{"tag5"}}, "val2 desc", this), + valsum("valsum", {{"tag4"},{"snaptest"}}, "valsum desc", this) { valsum.addMetricToSum(val1); valsum.addMetricToSum(val2); @@ -91,16 +91,17 @@ struct MultiSubMetricSet }; MultiSubMetricSet::MultiSubMetricSet(MetricSet* owner) - : set("multisub", "multisub", "", owner), - count("count", "snaptest", "counter", &set), - a("a", &set), - b("b", &set), - sum("sum", "snaptest", "", &set) + : set("multisub", {{"multisub"}}, "", owner), + count("count", {{"snaptest"}}, "counter", &set), + a("a", &set), + b("b", &set), + sum("sum", {{"snaptest"}}, "", &set) { sum.addMetricToSum(a); sum.addMetricToSum(b); } - MultiSubMetricSet::~MultiSubMetricSet() { } + +MultiSubMetricSet::~MultiSubMetricSet() { } struct TestMetricSet { MetricSet set; @@ -120,15 +121,15 @@ struct TestMetricSet { }; TestMetricSet::TestMetricSet() - : set("temp", "test", "desc of test set"), - val1("val1", "tag1", "val1 desc", &set), - val2("val2", "tag1 tag2", "val2 desc", &set), - val3("val3", "tag2 tag3", "val3 desc", &set), - val4("val4", "tag3", "val4 desc", &set), - val5("val5", "tag2", "val5 desc", &set), - val6("val6", "tag4 snaptest", "val6 desc", &set), - val7("val7", "", "val7 desc", &set), - val8("val8", "tag6", "val8 desc", &set), + : set("temp", {{"test"}}, "desc of test set"), + val1("val1", {{"tag1"}}, "val1 desc", &set), + val2("val2", {{"tag1"},{"tag2"}}, "val2 desc", &set), + val3("val3", {{"tag2"},{"tag3"}}, "val3 desc", &set), + val4("val4", {{"tag3"}}, "val4 desc", &set), + val5("val5", {{"tag2"}}, "val5 desc", &set), + val6("val6", {{"tag4"},{"snaptest"}}, "val6 desc", &set), + val7("val7", {}, "val7 desc", &set), + val8("val8", {{"tag6"}}, "val8 desc", &set), val9("sub", &set), val10(&set) { } @@ -967,7 +968,7 @@ struct DimensionTestMetricSet : MetricSet DimensionTestMetricSet::DimensionTestMetricSet(MetricSet* owner) : MetricSet("temp", {{"foo", "megafoo"}, {"bar", "hyperbar"}}, "", owner), - val1("val1", "tag1", "val1 desc", this), + val1("val1", {{"tag1"}}, "val1 desc", this), val2("val2", {{"baz", "superbaz"}}, "val2 desc", this) { } DimensionTestMetricSet::~DimensionTestMetricSet() { } @@ -1039,7 +1040,7 @@ struct DimensionOverridableTestMetricSet : MetricSet DimensionOverridableTestMetricSet(const std::string& dimValue, MetricSet* owner = nullptr) : MetricSet("temp", {{"foo", dimValue}}, "", owner), - val("val", "", "val desc", this) + val("val", {}, "val desc", this) { } }; diff --git a/metrics/src/tests/metricsettest.cpp b/metrics/src/tests/metricsettest.cpp index 3deddfc2507..e4601a7b573 100644 --- a/metrics/src/tests/metricsettest.cpp +++ b/metrics/src/tests/metricsettest.cpp @@ -47,12 +47,12 @@ void MetricSetTest::testNormalUsage() { // Set up some metrics to test.. - MetricSet set("a", "foo", ""); - DoubleValueMetric v1("c", "foo", "", &set); - LongAverageMetric v2("b", "", "", &set); - LongCountMetric v3("d", "bar", "", &set); - MetricSet set2("e", "bar", "", &set); - LongCountMetric v4("f", "foo", "", &set2); + MetricSet set("a", {{"foo"}}, ""); + DoubleValueMetric v1("c", {{"foo"}}, "", &set); + LongAverageMetric v2("b", {}, "", &set); + LongCountMetric v3("d", {{"bar"}}, "", &set); + MetricSet set2("e", {{"bar"}}, "", &set); + LongCountMetric v4("f", {{"foo"}}, "", &set2); // Give them some values v1.addValue(4.2); @@ -61,7 +61,7 @@ MetricSetTest::testNormalUsage() v4.inc(3); // Check that we can register through registerMetric function too. - LongCountMetric v5("g", "", ""); + LongCountMetric v5("g", {}, ""); set.registerMetric(v5); v5.inc(3); v5.dec(); @@ -77,7 +77,7 @@ MetricSetTest::testNormalUsage() CPPUNIT_ASSERT(nonExistingCopy == 0); // Check that paths are set - MetricSet topSet("top", "", ""); + MetricSet topSet("top", {}, ""); topSet.registerMetric(set); CPPUNIT_ASSERT_EQUAL(vespalib::string("a"), set.getPath()); CPPUNIT_ASSERT_EQUAL(vespalib::string("a.c"), v1.getPath()); @@ -136,10 +136,10 @@ MetricSetTest::supportMultipleMetricsWithSameNameDifferentDimensions() void MetricSetTest::uniqueTargetMetricsAreAddedToMetricSet() { - MetricSet set1("a", "foo", ""); - LongCountMetric v1("wow", "foo", "", &set1); - MetricSet set2("e", "bar", ""); - LongCountMetric v2("doge", "foo", "", &set2); + MetricSet set1("a", {{"foo"}}, ""); + LongCountMetric v1("wow", {{"foo"}}, "", &set1); + MetricSet set2("e", {{"bar"}}, ""); + LongCountMetric v2("doge", {{"foo"}}, "", &set2); // Have to actually assign a value to metrics or they won't be carried over. v1.inc(); diff --git a/metrics/src/tests/metrictest.cpp b/metrics/src/tests/metrictest.cpp index d9c39ef5cd2..eb1f5943a87 100644 --- a/metrics/src/tests/metrictest.cpp +++ b/metrics/src/tests/metrictest.cpp @@ -102,7 +102,7 @@ MetricTest::manglingDoesNotChangeOriginalMetricName() void MetricTest::legacyTagsDoNotCreateMangledName() { - LongValueMetric m("test", "foo bar", ""); + LongValueMetric m("test", {{"foo"},{"bar"}}, ""); CPPUNIT_ASSERT_EQUAL(vespalib::string("test"), m.getName()); CPPUNIT_ASSERT_EQUAL(vespalib::string("test"), m.getMangledName()); } diff --git a/metrics/src/tests/snapshottest.cpp b/metrics/src/tests/snapshottest.cpp index 75af75999d1..df9dd0a1e64 100644 --- a/metrics/src/tests/snapshottest.cpp +++ b/metrics/src/tests/snapshottest.cpp @@ -45,21 +45,21 @@ struct SubSubMetricSet : public MetricSet { }; SubSubMetricSet::SubSubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner) - : MetricSet(name, "", "", owner), + : MetricSet(name, {}, "", owner), loadTypes(loadTypes_), incVal(1), - count1("count1", "", "", this), - count2("count2", "", "", this), - loadCount(loadTypes, LongCountMetric("loadCount", "", ""), this), - countSum("countSum", "", "", this), - value1("value1", "", "", this), - value2("value2", "", "", this), - loadValue(loadTypes, DoubleValueMetric("loadValue", "", ""), this), - valueSum("valueSum", "", "", this), - average1("average1", "", "", this), - average2("average2", "", "", this), - loadAverage(loadTypes, DoubleAverageMetric("loadAverage", "", ""), this), - averageSum("averageSum", "", "", this) + count1("count1", {}, "", this), + count2("count2", {}, "", this), + loadCount(loadTypes, LongCountMetric("loadCount", {}, ""), this), + countSum("countSum", {}, "", this), + value1("value1", {}, "", this), + value2("value2", {}, "", this), + loadValue(loadTypes, DoubleValueMetric("loadValue", {}, ""), this), + valueSum("valueSum", {}, "", this), + average1("average1", {}, "", this), + average2("average2", {}, "", this), + loadAverage(loadTypes, DoubleAverageMetric("loadAverage", {}, ""), this), + averageSum("averageSum", {}, "", this) { countSum.addMetricToSum(count1); countSum.addMetricToSum(count2); @@ -120,12 +120,12 @@ struct SubMetricSet : public MetricSet { }; SubMetricSet::SubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner) - : MetricSet(name, "", "", owner), + : MetricSet(name, {}, "", owner), loadTypes(loadTypes_), set1("set1", loadTypes, this), set2("set2", loadTypes, this), loadSet(loadTypes, *std::unique_ptr<SubSubMetricSet>(new SubSubMetricSet("loadSet", loadTypes)), this), - setSum("setSum", "", "", this) + setSum("setSum", {}, "", this) { setSum.addMetricToSum(set1); setSum.addMetricToSum(set2); @@ -167,12 +167,12 @@ struct TestMetricSet : public MetricSet { TestMetricSet::TestMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner) - : MetricSet(name, "", "", owner), + : MetricSet(name, {}, "", owner), loadTypes(loadTypes_), set1("set1", loadTypes, this), set2("set2", loadTypes, this), loadSet(loadTypes, *std::unique_ptr<SubMetricSet>(new SubMetricSet("loadSet", loadTypes)), this), - setSum("setSum", "", "", this) + setSum("setSum", {}, "", this) { setSum.addMetricToSum(set1); setSum.addMetricToSum(set2); diff --git a/metrics/src/tests/stresstest.cpp b/metrics/src/tests/stresstest.cpp index 0c06ca70aec..e20045ad2d4 100644 --- a/metrics/src/tests/stresstest.cpp +++ b/metrics/src/tests/stresstest.cpp @@ -38,13 +38,13 @@ struct InnerMetricSet : public MetricSet { }; InnerMetricSet::InnerMetricSet(const char* name, const LoadTypeSet& lt, MetricSet* owner) - : MetricSet(name, "", "", owner), + : MetricSet(name, {}, "", owner), _loadTypes(lt), - _count("count", "", "", this), - _value1("value1", "", "", this), - _value2("value2", "", "", this), - _valueSum("valuesum", "", "", this), - _load(lt, LongAverageMetric("load", "", ""), this) + _count("count", {}, "", this), + _value1("value1", {}, "", this), + _value2("value2", {}, "", this), + _valueSum("valuesum", {}, "", this), + _load(lt, LongAverageMetric("load", {}, ""), this) { _valueSum.addMetricToSum(_value1); _valueSum.addMetricToSum(_value2); @@ -75,10 +75,10 @@ struct OuterMetricSet : public MetricSet { }; OuterMetricSet::OuterMetricSet(const LoadTypeSet& lt, MetricSet* owner) - : MetricSet("outer", "", "", owner), + : MetricSet("outer", {}, "", owner), _inner1("inner1", lt, this), _inner2("inner2", lt, this), - _innerSum("innersum", "", "", this), + _innerSum("innersum", {}, "", this), _tmp("innertmp", lt, 0), _load(lt, _tmp, this) { diff --git a/metrics/src/tests/summetrictest.cpp b/metrics/src/tests/summetrictest.cpp index 8cc622d622a..32c5ee2c309 100644 --- a/metrics/src/tests/summetrictest.cpp +++ b/metrics/src/tests/summetrictest.cpp @@ -25,11 +25,11 @@ CPPUNIT_TEST_SUITE_REGISTRATION(SumMetricTest); void SumMetricTest::testLongCountMetric() { - MetricSet parent("parent", "", ""); - SumMetric<LongCountMetric> sum("foo", "", "foodesc", &parent); + MetricSet parent("parent", {}, ""); + SumMetric<LongCountMetric> sum("foo", {}, "foodesc", &parent); - LongCountMetric v1("ff", "", "", &parent); - LongCountMetric v2("aa", "", "", &parent); + LongCountMetric v1("ff", {}, "", &parent); + LongCountMetric v2("aa", {}, "", &parent); sum.addMetricToSum(v1); sum.addMetricToSum(v2); @@ -46,11 +46,11 @@ SumMetricTest::testLongCountMetric() void SumMetricTest::testAverageMetric() { - MetricSet parent("parent", "", ""); - SumMetric<LongAverageMetric> sum("foo", "", "foodesc", &parent); + MetricSet parent("parent", {}, ""); + SumMetric<LongAverageMetric> sum("foo", {}, "foodesc", &parent); - LongAverageMetric v1("ff", "", "", &parent); - LongAverageMetric v2("aa", "", "", &parent); + LongAverageMetric v1("ff", {}, "", &parent); + LongAverageMetric v2("aa", {}, "", &parent); sum.addMetricToSum(v1); sum.addMetricToSum(v2); @@ -69,15 +69,15 @@ SumMetricTest::testAverageMetric() { void SumMetricTest::testMetricSet() { - MetricSet parent("parent", "", ""); - SumMetric<MetricSet> sum("foo", "", "bar", &parent); + MetricSet parent("parent", {}, ""); + SumMetric<MetricSet> sum("foo", {}, "bar", &parent); - MetricSet set1("a", "", "", &parent); - MetricSet set2("b", "", "", &parent); - LongValueMetric v1("c", "", "", &set1); - LongValueMetric v2("d", "", "", &set2); - LongCountMetric v3("e", "", "", &set1); - LongCountMetric v4("f", "", "", &set2); + MetricSet set1("a", {}, "", &parent); + MetricSet set2("b", {}, "", &parent); + LongValueMetric v1("c", {}, "", &set1); + LongValueMetric v2("d", {}, "", &set2); + LongCountMetric v3("e", {}, "", &set1); + LongCountMetric v4("f", {}, "", &set2); sum.addMetricToSum(set1); sum.addMetricToSum(set2); @@ -100,12 +100,12 @@ SumMetricTest::testMetricSet() { void SumMetricTest::testRemove() { - MetricSet parent("parent", "", ""); - SumMetric<LongCountMetric> sum("foo", "", "foodesc", &parent); + MetricSet parent("parent", {}, ""); + SumMetric<LongCountMetric> sum("foo", {}, "foodesc", &parent); - LongCountMetric v1("ff", "", "", &parent); - LongCountMetric v2("aa", "", "", &parent); - LongCountMetric v3("zz", "", "", &parent); + LongCountMetric v1("ff", {}, "", &parent); + LongCountMetric v2("aa", {}, "", &parent); + LongCountMetric v3("zz", {}, "", &parent); sum.addMetricToSum(v1); sum.addMetricToSum(v2); @@ -125,9 +125,9 @@ void SumMetricTest::testStartValue() { MetricSnapshot snapshot("active"); - SumMetric<LongValueMetric> sum("foo", "", "foodesc", + SumMetric<LongValueMetric> sum("foo", {}, "foodesc", &snapshot.getMetrics()); - LongValueMetric start("start", "", "", 0); + LongValueMetric start("start", {}, "", 0); start.set(50); sum.setStartValue(start); @@ -138,7 +138,7 @@ SumMetricTest::testStartValue() copy.recreateSnapshot(snapshot.getMetrics(), true); snapshot.addToSnapshot(copy, 100); - LongValueMetric value("value", "", "", &snapshot.getMetrics()); + LongValueMetric value("value", {}, "", &snapshot.getMetrics()); sum.addMetricToSum(value); value.set(10); diff --git a/metrics/src/tests/valuemetrictest.cpp b/metrics/src/tests/valuemetrictest.cpp index e8c144c96aa..da730b7c8a9 100644 --- a/metrics/src/tests/valuemetrictest.cpp +++ b/metrics/src/tests/valuemetrictest.cpp @@ -46,7 +46,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(ValueMetricTest); void ValueMetricTest::testDoubleValueMetric() { - DoubleValueMetric m("test", "tag", "description"); + DoubleValueMetric m("test", {{"tag"}}, "description"); m.addValue(100); ASSERT_AVERAGE(m, 100, 100, 100, 1, 100); m.addValue(100); @@ -58,7 +58,7 @@ void ValueMetricTest::testDoubleValueMetric() m.reset(); ASSERT_AVERAGE(m, 0, 0, 0, 0, 0); - DoubleValueMetric n("m2", "", "desc"); + DoubleValueMetric n("m2", {}, "desc"); n.addValue(60); ASSERT_AVERAGE(n, 60, 60, 60, 1, 60); @@ -94,7 +94,7 @@ void ValueMetricTest::testDoubleValueMetric() void ValueMetricTest::testDoubleValueMetricNotUpdatedOnNaN() { - DoubleValueMetric m("test", "tag", "description"); + DoubleValueMetric m("test", {{"tag"}}, "description"); m.addValue(std::numeric_limits<double>::quiet_NaN()); CPPUNIT_ASSERT_EQUAL(std::string(), m.toString()); @@ -111,7 +111,7 @@ ValueMetricTest::testDoubleValueMetricNotUpdatedOnNaN() void ValueMetricTest::testDoubleValueMetricNotUpdatedOnInfinity() { - DoubleValueMetric m("test", "tag", "description"); + DoubleValueMetric m("test", {{"tag"}}, "description"); m.addValue(std::numeric_limits<double>::infinity()); CPPUNIT_ASSERT_EQUAL(std::string(), m.toString()); @@ -127,7 +127,7 @@ ValueMetricTest::testDoubleValueMetricNotUpdatedOnInfinity() void ValueMetricTest::testLongValueMetric() { - LongValueMetric m("test", "tag", "description"); + LongValueMetric m("test", {{"tag"}}, "description"); m.addValue(100); ASSERT_AVERAGE(m, 100, 100, 100, 1, 100); m.addValue(100); @@ -139,7 +139,7 @@ void ValueMetricTest::testLongValueMetric() m.reset(); ASSERT_AVERAGE(m, 0, 0, 0, 0, 0); - LongValueMetric n("m2", "", "desc"); + LongValueMetric n("m2", {}, "desc"); n.addValue(60); ASSERT_AVERAGE(n, 60, 60, 60, 1, 60); @@ -174,7 +174,7 @@ void ValueMetricTest::testLongValueMetric() void ValueMetricTest::testSmallAverage() { - DoubleValueMetric m("test", "tag", "description"); + DoubleValueMetric m("test", {{"tag"}}, "description"); m.addValue(0.0001); m.addValue(0.0002); m.addValue(0.0003); @@ -186,7 +186,7 @@ void ValueMetricTest::testSmallAverage() } void ValueMetricTest::testAddValueBatch() { - DoubleValueMetric m("test", "tag", "description"); + DoubleValueMetric m("test", {{"tag"}}, "description"); m.addValueBatch(100, 3, 80, 120); ASSERT_AVERAGE(m, 100, 80, 120, 3, 100); m.addValueBatch(123, 0, 12, 1234); @@ -222,7 +222,7 @@ namespace { void ValueMetricTest::testJson() { MetricManager mm; - DoubleValueMetric m("test", "tag", "description"); + DoubleValueMetric m("test", {{"tag"}}, "description"); mm.registerMetric(mm.getMetricLock(), m); vespalib::string expected("'\n" diff --git a/metrics/src/vespa/metrics/countmetric.h b/metrics/src/vespa/metrics/countmetric.h index 912fc52449b..675b5698049 100644 --- a/metrics/src/vespa/metrics/countmetric.h +++ b/metrics/src/vespa/metrics/countmetric.h @@ -28,12 +28,6 @@ struct AbstractCountMetric : public Metric { virtual bool inUse(const MetricValueClass& v) const = 0; protected: - AbstractCountMetric(const String& name, const String& tags, - const String& description, MetricSet* owner = 0) - : Metric(name, tags, description, owner) - { - } - AbstractCountMetric(const String& name, Tags dimensions, const String& description, MetricSet* owner = 0) : Metric(name, std::move(dimensions), description, owner) @@ -60,9 +54,6 @@ class CountMetric : public AbstractCountMetric bool logIfUnset() const { return _values.hasFlag(LOG_IF_UNSET); } public: - CountMetric(const String& name, const String& tags, - const String& description, MetricSet* owner = 0); - CountMetric(const String& name, Tags dimensions, const String& description, MetricSet* owner = 0); diff --git a/metrics/src/vespa/metrics/countmetric.hpp b/metrics/src/vespa/metrics/countmetric.hpp index b46d45d690f..810ba7e371d 100644 --- a/metrics/src/vespa/metrics/countmetric.hpp +++ b/metrics/src/vespa/metrics/countmetric.hpp @@ -8,15 +8,6 @@ namespace metrics { template <typename T, bool SumOnAdd> -CountMetric<T, SumOnAdd>::CountMetric(const String& name, const String& tags, - const String& desc, MetricSet* owner) - : AbstractCountMetric(name, tags, desc, owner), - _values() -{ - _values.setFlag(LOG_IF_UNSET); -} - -template <typename T, bool SumOnAdd> CountMetric<T, SumOnAdd>::CountMetric(const String& name, Tags dimensions, const String& desc, MetricSet* owner) : AbstractCountMetric(name, std::move(dimensions), desc, owner), diff --git a/metrics/src/vespa/metrics/loadmetric.hpp b/metrics/src/vespa/metrics/loadmetric.hpp index 0a66f985867..ce93c761a05 100644 --- a/metrics/src/vespa/metrics/loadmetric.hpp +++ b/metrics/src/vespa/metrics/loadmetric.hpp @@ -10,9 +10,9 @@ namespace metrics { template<typename MetricType> LoadMetric<MetricType>::LoadMetric(const LoadTypeSet& loadTypes, const MetricType& metric, MetricSet* owner) - : MetricSet(metric.getName(), "", metric.getDescription(), owner), + : MetricSet(metric.getName(), {}, metric.getDescription(), owner), _metrics(), - _sum("sum", "loadsum sum", "Sum of all load metrics", this) + _sum("sum", {{"loadsum"},{"sum"}}, "Sum of all load metrics", this) { _metrics.resize(loadTypes.size()); // Currently, we only set tags and description on the metric set @@ -35,9 +35,9 @@ LoadMetric<MetricType>::LoadMetric(const LoadTypeSet& loadTypes, const MetricTyp template<typename MetricType> LoadMetric<MetricType>::LoadMetric(const LoadMetric<MetricType>& other, MetricSet* owner) - : MetricSet(other.getName(), "", other.getDescription(), owner), + : MetricSet(other.getName(), {}, other.getDescription(), owner), _metrics(), - _sum("sum", "loadsum sum", "Sum of all load metrics", this) + _sum("sum", {{"loadsum"},{"sum"}}, "Sum of all load metrics", this) { _metrics.resize(2 * other._metrics.size()); setTags(other.getTags()); diff --git a/metrics/src/vespa/metrics/metric.cpp b/metrics/src/vespa/metrics/metric.cpp index 05483a5be11..82f9c848ece 100644 --- a/metrics/src/vespa/metrics/metric.cpp +++ b/metrics/src/vespa/metrics/metric.cpp @@ -37,20 +37,15 @@ MetricVisitor::visitMetric(const Metric&, bool) } namespace { - Metric::Tags legacyTagStringToKeyedTags(const std::string& tagStr) { - vespalib::StringTokenizer tokenizer(tagStr, " \t\r\f"); - Metric::Tags tags; - std::transform(tokenizer.getTokens().begin(), - tokenizer.getTokens().end(), - std::back_inserter(tags), - [](const std::string& s) { return Tag(s, ""); }); - return tags; - } std::string namePattern = "[a-zA-Z][_a-zA-Z0-9]*"; } vespalib::Regexp Metric::_namePattern(namePattern); +Tag::Tag(vespalib::stringref k) + : _key(NameRepo::tagKeyId(k)), + _value(0) +{ } Tag::Tag(vespalib::stringref k, vespalib::stringref v) : _key(NameRepo::tagKeyId(k)), _value(NameRepo::tagValueId(v)) @@ -61,21 +56,6 @@ Tag & Tag::operator = (const Tag &) = default; Tag::~Tag() {} Metric::Metric(const String& name, - const String& tags, - const String& description, - MetricSet* owner) - : _name(NameRepo::metricId(name)), - _mangledName(_name), - _description(NameRepo::descriptionId(description)), - _tags(legacyTagStringToKeyedTags(tags)), - _owner(nullptr) // Set later by registry -{ - verifyConstructionParameters(); - assignMangledNameWithDimensions(); - registerWithOwnerIfRequired(owner); -} - -Metric::Metric(const String& name, Tags dimensions, const String& description, MetricSet* owner) @@ -111,7 +91,7 @@ Metric::~Metric() { } bool Metric::tagsSpecifyAtLeastOneDimension(const Tags& tags) const { - auto hasNonEmptyTagValue = [](const Tag& t) { return !t.value().empty(); }; + auto hasNonEmptyTagValue = [](const Tag& t) { return t.hasValue(); }; return std::any_of(tags.begin(), tags.end(), hasNonEmptyTagValue); } diff --git a/metrics/src/vespa/metrics/metric.h b/metrics/src/vespa/metrics/metric.h index dc9e45e89af..c92cad8c0cd 100644 --- a/metrics/src/vespa/metrics/metric.h +++ b/metrics/src/vespa/metrics/metric.h @@ -86,6 +86,7 @@ struct Tag const vespalib::string& key() const { return NameRepo::tagKey(_key); } const vespalib::string& value() const { return NameRepo::tagValue(_value); } + Tag(vespalib::stringref k); Tag(vespalib::stringref k, vespalib::stringref v); Tag(const Tag &); Tag & operator = (const Tag &); @@ -93,6 +94,8 @@ struct Tag Tag & operator = (Tag &&) = default; ~Tag(); + bool hasValue() const { return _value.id() != 0; } + private: TagKeyId _key; TagValueId _value; @@ -109,9 +112,6 @@ public: static vespalib::Regexp _namePattern; - Metric(const String& name, const String& tags, - const String& description, MetricSet* owner = 0); - Metric(const String& name, Tags dimensions, const String& description, diff --git a/metrics/src/vespa/metrics/metricmanager.cpp b/metrics/src/vespa/metrics/metricmanager.cpp index 544998e25cd..5b716e2698f 100644 --- a/metrics/src/vespa/metrics/metricmanager.cpp +++ b/metrics/src/vespa/metrics/metricmanager.cpp @@ -75,12 +75,12 @@ MetricManager::MetricManager(std::unique_ptr<Timer> timer) _forceEventLogging(false), _snapshotUnsetMetrics(false), _consumerConfigChanged(false), - _metricManagerMetrics("metricmanager", "", "Metrics for the metric manager upkeep tasks"), - _periodicHookLatency("periodichooklatency", "", "Time in ms used to update a single periodic hook", &_metricManagerMetrics), - _snapshotHookLatency("snapshothooklatency", "", "Time in ms used to update a single snapshot hook", &_metricManagerMetrics), - _resetLatency("resetlatency", "", "Time in ms used to reset all metrics.", &_metricManagerMetrics), - _snapshotLatency("snapshotlatency", "", "Time in ms used to take a snapshot", &_metricManagerMetrics), - _sleepTimes("sleeptime", "", "Time in ms worker thread is sleeping", &_metricManagerMetrics) + _metricManagerMetrics("metricmanager", {}, "Metrics for the metric manager upkeep tasks"), + _periodicHookLatency("periodichooklatency", {}, "Time in ms used to update a single periodic hook", &_metricManagerMetrics), + _snapshotHookLatency("snapshothooklatency", {}, "Time in ms used to update a single snapshot hook", &_metricManagerMetrics), + _resetLatency("resetlatency", {}, "Time in ms used to reset all metrics.", &_metricManagerMetrics), + _snapshotLatency("snapshotlatency", {}, "Time in ms used to take a snapshot", &_metricManagerMetrics), + _sleepTimes("sleeptime", {}, "Time in ms worker thread is sleeping", &_metricManagerMetrics) { registerMetric(getMetricLock(), _metricManagerMetrics); } diff --git a/metrics/src/vespa/metrics/metricset.cpp b/metrics/src/vespa/metrics/metricset.cpp index 6ffae806322..a8e22c8dfc4 100644 --- a/metrics/src/vespa/metrics/metricset.cpp +++ b/metrics/src/vespa/metrics/metricset.cpp @@ -14,14 +14,6 @@ LOG_SETUP(".metrics.metricsset"); namespace metrics { -MetricSet::MetricSet(const String& name, const String& tags, - const String& description, MetricSet* owner) - : Metric(name, tags, description, owner), - _metricOrder(), - _registrationAltered(false) -{ -} - MetricSet::MetricSet(const String& name, Tags dimensions, const String& description, MetricSet* owner) : Metric(name, std::move(dimensions), description, owner), diff --git a/metrics/src/vespa/metrics/metricset.h b/metrics/src/vespa/metrics/metricset.h index a8fea2fc290..da3f2c26cde 100644 --- a/metrics/src/vespa/metrics/metricset.h +++ b/metrics/src/vespa/metrics/metricset.h @@ -22,9 +22,6 @@ class MetricSet : public Metric // it was reset public: - MetricSet(const String& name, const String& tags, - const String& description, MetricSet* owner = 0); - MetricSet(const String& name, Tags dimensions, const String& description, MetricSet* owner = 0); diff --git a/metrics/src/vespa/metrics/metricsnapshot.cpp b/metrics/src/vespa/metrics/metricsnapshot.cpp index ac3c41215aa..86a33f0993f 100644 --- a/metrics/src/vespa/metrics/metricsnapshot.cpp +++ b/metrics/src/vespa/metrics/metricsnapshot.cpp @@ -12,7 +12,7 @@ MetricSnapshot::MetricSnapshot(const Metric::String& name) _period(0), _fromTime(0), _toTime(0), - _snapshot(new MetricSet("top", "", "")), + _snapshot(new MetricSet("top", {}, "")), _metrics() { } diff --git a/metrics/src/vespa/metrics/summetric.h b/metrics/src/vespa/metrics/summetric.h index 3dc58d32bef..a9827bcca7d 100644 --- a/metrics/src/vespa/metrics/summetric.h +++ b/metrics/src/vespa/metrics/summetric.h @@ -42,7 +42,7 @@ private: std::vector<const AddendMetric*> _metricsToSum; public: - SumMetric(const String& name, const String& tags, const String& description, MetricSet* owner = 0); + SumMetric(const String& name, Tags tags, const String& description, MetricSet* owner = 0); SumMetric(const SumMetric<AddendMetric>& other, std::vector<Metric::UP> & ownerList, MetricSet* owner = 0); ~SumMetric(); diff --git a/metrics/src/vespa/metrics/summetric.hpp b/metrics/src/vespa/metrics/summetric.hpp index 8e558eb94ee..fc3c3a5e019 100644 --- a/metrics/src/vespa/metrics/summetric.hpp +++ b/metrics/src/vespa/metrics/summetric.hpp @@ -24,7 +24,7 @@ SumMetric<AddendMetric>::visit(MetricVisitor& visitor, } template<typename AddendMetric> -SumMetric<AddendMetric>::SumMetric(const String& name, const String& tags, +SumMetric<AddendMetric>::SumMetric(const String& name, Tags tags, const String& description, MetricSet* owner) : Metric(name, tags, description, owner), _startValue(), diff --git a/metrics/src/vespa/metrics/valuemetric.h b/metrics/src/vespa/metrics/valuemetric.h index 57baa36c26a..44a4e551cba 100644 --- a/metrics/src/vespa/metrics/valuemetric.h +++ b/metrics/src/vespa/metrics/valuemetric.h @@ -28,10 +28,6 @@ struct AbstractValueMetric : public Metric { virtual bool summedAverage() const = 0; protected: - AbstractValueMetric(const String& name, const String& tags, - const String& description, MetricSet* owner) - : Metric(name, tags, description, owner) {} - AbstractValueMetric(const String& name, Tags dimensions, const String& description, MetricSet* owner) : Metric(name, std::move(dimensions), description, owner) {} @@ -83,9 +79,6 @@ class ValueMetric : public AbstractValueMetric { bool checkFinite(AvgVal, std::false_type) { return true; } public: - ValueMetric(const String &name, const String &tags, - const String &description, MetricSet *owner = 0); - ValueMetric(const ValueMetric<AvgVal, TotVal, SumOnAdd> &, CopyType, MetricSet *owner); diff --git a/metrics/src/vespa/metrics/valuemetric.hpp b/metrics/src/vespa/metrics/valuemetric.hpp index 8fe8769e9ad..8b2ee532614 100644 --- a/metrics/src/vespa/metrics/valuemetric.hpp +++ b/metrics/src/vespa/metrics/valuemetric.hpp @@ -11,16 +11,6 @@ namespace metrics { template<typename AvgVal, typename TotVal, bool SumOnAdd> ValueMetric<AvgVal, TotVal, SumOnAdd>::ValueMetric( - const String& name, const String& tags, - const String& description, MetricSet* owner) - : AbstractValueMetric(name, tags, description, owner), - _values() -{ - _values.setFlag(LOG_IF_UNSET); -} - -template<typename AvgVal, typename TotVal, bool SumOnAdd> -ValueMetric<AvgVal, TotVal, SumOnAdd>::ValueMetric( const String& name, const Tags dimensions, const String& description, MetricSet* owner) : AbstractValueMetric(name, std::move(dimensions), description, owner), |