Skip to content

Commit

Permalink
remove legacy tags, always pass vector
Browse files Browse the repository at this point in the history
  • Loading branch information
arnej27959 committed Oct 8, 2018
1 parent 3f8389d commit b42a5ef
Show file tree
Hide file tree
Showing 57 changed files with 501 additions and 545 deletions.
4 changes: 2 additions & 2 deletions metrics/src/tests/countmetrictest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());

Expand Down
10 changes: 5 additions & 5 deletions metrics/src/tests/loadmetrictest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ LoadMetricTest::testNormalUsage()
LoadTypeSetImpl loadTypes;
loadTypes.add(32, "foo").add(1000, "bar");
LoadMetric<LongValueMetric> metric(
loadTypes, LongValueMetric("put", "", "Put"));
loadTypes, LongValueMetric("put", {}, "Put"));
}

namespace {
struct MyMetricSet : public MetricSet {
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,
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion metrics/src/tests/metric_timer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 22 additions & 21 deletions metrics/src/tests/metricmanagertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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)
{ }
Expand Down Expand Up @@ -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() { }
Expand Down Expand Up @@ -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)
{ }
};

Expand Down
24 changes: 12 additions & 12 deletions metrics/src/tests/metricsettest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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());
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion metrics/src/tests/metrictest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
34 changes: 17 additions & 17 deletions metrics/src/tests/snapshottest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions metrics/src/tests/stresstest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down
Loading

0 comments on commit b42a5ef

Please sign in to comment.