aboutsummaryrefslogtreecommitdiffstats
path: root/metrics
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-11-27 16:04:42 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-11-27 16:04:42 +0000
commit970964693e9ef9eab47d506286a20216ec477ba8 (patch)
tree2e293030bbb5445ac394107ebc64997a8e346b14 /metrics
parentf415fcff4c0ccd7c13a3740fbdca829a0c88484b (diff)
GC loadmetric that is decommisioned.
Diffstat (limited to 'metrics')
-rw-r--r--metrics/src/tests/CMakeLists.txt1
-rw-r--r--metrics/src/tests/loadmetrictest.cpp128
-rw-r--r--metrics/src/tests/snapshottest.cpp135
-rw-r--r--metrics/src/tests/stresstest.cpp53
-rw-r--r--metrics/src/vespa/metrics/CMakeLists.txt1
-rw-r--r--metrics/src/vespa/metrics/loadmetric.cpp20
-rw-r--r--metrics/src/vespa/metrics/loadmetric.h66
-rw-r--r--metrics/src/vespa/metrics/loadmetric.hpp102
-rw-r--r--metrics/src/vespa/metrics/loadtype.h25
9 files changed, 30 insertions, 501 deletions
diff --git a/metrics/src/tests/CMakeLists.txt b/metrics/src/tests/CMakeLists.txt
index 1e3578e065b..2f517d0065d 100644
--- a/metrics/src/tests/CMakeLists.txt
+++ b/metrics/src/tests/CMakeLists.txt
@@ -4,7 +4,6 @@
vespa_add_executable(metrics_gtest_runner_app TEST
SOURCES
countmetrictest.cpp
- loadmetrictest.cpp
metric_timer_test.cpp
metricmanagertest.cpp
metricsettest.cpp
diff --git a/metrics/src/tests/loadmetrictest.cpp b/metrics/src/tests/loadmetrictest.cpp
deleted file mode 100644
index b89628f4476..00000000000
--- a/metrics/src/tests/loadmetrictest.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/metrics/loadmetric.h>
-#include <vespa/metrics/valuemetric.h>
-#include <vespa/metrics/loadmetric.hpp>
-#include <vespa/metrics/summetric.hpp>
-#include <vespa/vespalib/gtest/gtest.h>
-
-namespace metrics {
-
-struct LoadTypeSetImpl : public LoadTypeSet {
- LoadTypeSetImpl() {
- push_back(LoadType(0, "default"));
- }
- LoadTypeSetImpl& add(uint32_t id, const char* name) {
- push_back(LoadType(id, name));
- return *this;
- }
- const LoadType& operator[](const std::string& name) const {
- for (uint32_t i=0; i<size(); ++i) {
- const LoadType& lt(LoadTypeSet::operator[](i));
- if (lt.getName() == name) return lt;
- }
- abort();
- }
-};
-
-TEST(LoadMetricTest, test_normal_usage)
-{
- LoadTypeSetImpl loadTypes;
- loadTypes.add(32, "foo").add(1000, "bar");
- LoadMetric<LongValueMetric> metric(
- loadTypes, LongValueMetric("put", {}, "Put"));
-}
-
-namespace {
- struct MyMetricSet : public MetricSet {
- LongAverageMetric metric;
-
- MyMetricSet(MetricSet* owner = 0)
- : MetricSet("tick", {}, "", owner),
- metric("tack", {}, "", this)
- { }
-
- MetricSet* clone(std::vector<Metric::UP> &ownerList, CopyType copyType,
- MetricSet* owner, bool includeUnused = false) const override
- {
- if (copyType != CLONE) {
- return MetricSet::clone(ownerList, copyType, owner, includeUnused);
- }
- MyMetricSet * myset = new MyMetricSet(owner);
- myset->assignValues(*this);
- std::cerr << "org:" << this->toString(true) << std::endl;
- std::cerr << "clone:" << myset->toString(true) << std::endl;
- return myset;
- }
- };
-}
-
-void
-test_clone(Metric::CopyType copyType)
-{
- LoadTypeSetImpl loadTypes;
- loadTypes.add(32, "foo").add(1000, "bar");
- MetricSet top("top", {}, "");
- MyMetricSet myset;
- LoadMetric<MyMetricSet> metric(loadTypes, myset, &top);
- metric[loadTypes["foo"]].metric.addValue(5);
-
- std::vector<Metric::UP> ownerList;
- MetricSet::UP copy(dynamic_cast<MetricSet*>(top.clone(ownerList, copyType, 0, true)));
- ASSERT_TRUE(copy.get());
-
- std::string expected =
- "top:\n"
- " tick:\n"
- " sum:\n"
- " tack average=5 last=5 min=5 max=5 count=1 total=5\n"
- " default:\n"
- " tack average=0 last=0 count=0 total=0\n"
- " foo:\n"
- " tack average=5 last=5 min=5 max=5 count=1 total=5\n"
- " bar:\n"
- " tack average=0 last=0 count=0 total=0";
-
- EXPECT_EQ(expected, std::string(top.toString(true)));
- EXPECT_EQ(expected, std::string(copy->toString(true)));
-}
-
-TEST(LoadMetricTest, test_inactive_copy)
-{
- test_clone(Metric::INACTIVE);
-}
-
-TEST(LoadMetricTest, test_active_copy)
-{
- test_clone(Metric::CLONE);
-}
-
-TEST(LoadMetricTest, test_adding)
-{
- LoadTypeSetImpl loadTypes;
- loadTypes.add(32, "foo").add(1000, "bar");
- MetricSet top("top", {}, "");
- MyMetricSet myset;
- LoadMetric<MyMetricSet> metric(loadTypes, myset, &top);
- metric[loadTypes["foo"]].metric.addValue(5);
-
- std::vector<Metric::UP> ownerList;
- MetricSet::UP copy(dynamic_cast<MetricSet*>(
- top.clone(ownerList, Metric::INACTIVE, 0, false)));
- ASSERT_TRUE(copy.get());
-
- top.reset();
-
- top.addToSnapshot(*copy, ownerList);
-
- std::string expected =
- "top:\n"
- " tick:\n"
- " sum:\n"
- " tack average=5 last=5 min=5 max=5 count=1 total=5\n"
- " foo:\n"
- " tack average=5 last=5 min=5 max=5 count=1 total=5";
-
- EXPECT_EQ(expected, std::string(copy->toString(true)));
-}
-
-}
diff --git a/metrics/src/tests/snapshottest.cpp b/metrics/src/tests/snapshottest.cpp
index 8336af41a79..97dbf97aff5 100644
--- a/metrics/src/tests/snapshottest.cpp
+++ b/metrics/src/tests/snapshottest.cpp
@@ -1,6 +1,5 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/metrics/loadmetric.hpp>
#include <vespa/metrics/metricmanager.h>
#include <vespa/metrics/metrics.h>
#include <vespa/metrics/summetric.hpp>
@@ -11,43 +10,35 @@ namespace metrics {
namespace {
struct SubSubMetricSet : public MetricSet {
- const LoadTypeSet& loadTypes;
int incVal;
LongCountMetric count1;
LongCountMetric count2;
- LoadMetric<LongCountMetric> loadCount;
SumMetric<LongCountMetric> countSum;
DoubleValueMetric value1;
DoubleValueMetric value2;
- LoadMetric<DoubleValueMetric> loadValue;
SumMetric<DoubleValueMetric> valueSum;
DoubleAverageMetric average1;
DoubleAverageMetric average2;
- LoadMetric<DoubleAverageMetric> loadAverage;
SumMetric<DoubleAverageMetric> averageSum;
- SubSubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner = 0);
+ SubSubMetricSet(vespalib::stringref name, MetricSet* owner = 0);
~SubSubMetricSet();
MetricSet* clone(std::vector<Metric::UP> &ownerList, CopyType copyType,
metrics::MetricSet* owner, bool includeUnused) const override;
void incValues();
};
-SubSubMetricSet::SubSubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner)
+SubSubMetricSet::SubSubMetricSet(vespalib::stringref name, MetricSet* 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)
{
countSum.addMetricToSum(count1);
@@ -68,7 +59,7 @@ SubSubMetricSet::clone(std::vector<Metric::UP> &ownerList,
return MetricSet::clone(ownerList, INACTIVE, owner, includeUnused);
}
return (SubSubMetricSet*) (new SubSubMetricSet(
- getName(), loadTypes, owner))
+ getName(), owner))
->assignValues(*this);
}
@@ -76,30 +67,19 @@ void
SubSubMetricSet::incValues() {
count1.inc(incVal);
count2.inc(incVal);
- for (uint32_t i=0; i<loadTypes.size(); ++i) {
- loadCount[loadTypes[i]].inc(incVal);
- }
value1.set(incVal);
value2.set(incVal);
- for (uint32_t i=0; i<loadTypes.size(); ++i) {
- loadValue[loadTypes[i]].set(incVal);
- }
average1.set(incVal);
average2.set(incVal);
- for (uint32_t i=0; i<loadTypes.size(); ++i) {
- loadAverage[loadTypes[i]].set(incVal);
- }
}
struct SubMetricSet : public MetricSet {
- const LoadTypeSet& loadTypes;
SubSubMetricSet set1;
SubSubMetricSet set2;
- LoadMetric<SubSubMetricSet> loadSet;
SumMetric<SubSubMetricSet> setSum;
- SubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner = 0);
+ SubMetricSet(vespalib::stringref name, MetricSet* owner = 0);
~SubMetricSet();
MetricSet* clone(std::vector<Metric::UP> &ownerList, CopyType copyType,
@@ -108,12 +88,10 @@ struct SubMetricSet : public MetricSet {
void incValues();
};
-SubMetricSet::SubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner)
+SubMetricSet::SubMetricSet(vespalib::stringref name, MetricSet* 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),
+ set1("set1", this),
+ set2("set2", this),
setSum("setSum", {}, "", this)
{
setSum.addMetricToSum(set1);
@@ -128,7 +106,7 @@ SubMetricSet::clone(std::vector<Metric::UP> &ownerList, CopyType copyType,
if (copyType == INACTIVE) {
return MetricSet::clone(ownerList, INACTIVE, owner, includeUnused);
}
- return (SubMetricSet*) (new SubMetricSet(getName(), loadTypes, owner))
+ return (SubMetricSet*) (new SubMetricSet(getName(), owner))
->assignValues(*this);
}
@@ -136,31 +114,24 @@ void
SubMetricSet::incValues() {
set1.incValues();
set2.incValues();
- for (uint32_t i=0; i<loadTypes.size(); ++i) {
- loadSet[loadTypes[i]].incValues();
- }
}
struct TestMetricSet : public MetricSet {
- const LoadTypeSet& loadTypes;
SubMetricSet set1;
SubMetricSet set2;
- LoadMetric<SubMetricSet> loadSet;
SumMetric<SubMetricSet> setSum;
- TestMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner = 0);
+ TestMetricSet(vespalib::stringref name, MetricSet* owner = 0);
~TestMetricSet();
void incValues();
};
-TestMetricSet::TestMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner)
+TestMetricSet::TestMetricSet(vespalib::stringref name, MetricSet* 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),
+ set1("set1", this),
+ set2("set2", this),
setSum("setSum", {}, "", this)
{
setSum.addMetricToSum(set1);
@@ -172,9 +143,6 @@ void
TestMetricSet::incValues() {
set1.incValues();
set2.incValues();
- for (uint32_t i=0; i<loadTypes.size(); ++i) {
- loadSet[loadTypes[i]].incValues();
- }
}
struct FakeTimer : public MetricManager::Timer {
@@ -204,12 +172,7 @@ struct SnapshotTest : public ::testing::Test {
TEST_F(SnapshotTest, test_snapshot_two_days)
{
- // Create load types
- LoadTypeSet loadTypes;
- loadTypes.push_back(LoadType(1, "foo"));
- loadTypes.push_back(LoadType(2, "bar"));
-
- TestMetricSet set("test", loadTypes);
+ TestMetricSet set("test");
FakeTimer* timer;
FastOS_ThreadPool threadPool(256 * 1024);
@@ -256,113 +219,41 @@ TEST_F(SnapshotTest, test_snapshot_two_days)
MetricLockGuard lockGuard(mm.getMetricLock());
snap = &mm.getActiveMetrics(lockGuard);
ASSERT_VALUE(0, *snap, "test.set1.set1.count1");
- ASSERT_VALUE(0, *snap, "test.set1.set1.loadCount.foo");
- ASSERT_VALUE(0, *snap, "test.set1.set1.loadCount.sum");
ASSERT_VALUE(0, *snap, "test.set1.set1.countSum");
- ASSERT_VALUE(0, *snap, "test.set1.loadSet.foo.count1");
- ASSERT_VALUE(0, *snap, "test.set1.loadSet.foo.countSum");
/* Current test procedure for fetching values, don't work in active sums of sets
- ASSERT_VALUE(0, *snap, "test.set1.loadSet.sum.count1");
- ASSERT_VALUE(0, *snap, "test.set1.loadSet.sum.loadCount.foo");
- ASSERT_VALUE(0, *snap, "test.set1.loadSet.sum.loadCount.sum");
- ASSERT_VALUE(0, *snap, "test.set1.loadSet.sum.countSum");
*/
// 5 minute snapshot
snap = &mm.getMetricSnapshot(lockGuard, 5 * 60);
ASSERT_VALUE(1, *snap, "test.set1.set1.count1");
- ASSERT_VALUE(1, *snap, "test.set1.set1.loadCount.foo");
- ASSERT_VALUE(2, *snap, "test.set1.set1.loadCount.sum");
ASSERT_VALUE(2, *snap, "test.set1.set1.countSum");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.foo.count1");
- ASSERT_VALUE(2, *snap, "test.set1.loadSet.foo.countSum");
- ASSERT_VALUE(2, *snap, "test.set1.loadSet.sum.count1");
- ASSERT_VALUE(2, *snap, "test.set1.loadSet.sum.loadCount.foo");
- ASSERT_VALUE(4, *snap, "test.set1.loadSet.sum.loadCount.sum");
- ASSERT_VALUE(4, *snap, "test.set1.loadSet.sum.countSum");
ASSERT_VALUE(1, *snap, "test.set1.set1.average1");
- ASSERT_VALUE(1, *snap, "test.set1.set1.loadAverage.foo");
- ASSERT_VALUE(1, *snap, "test.set1.set1.loadAverage.sum");
ASSERT_VALUE(1, *snap, "test.set1.set1.averageSum");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.foo.average1");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.foo.averageSum");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.sum.average1");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.sum.loadAverage.foo");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.sum.loadAverage.sum");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.sum.averageSum");
// 1 hour snapshot
snap = &mm.getMetricSnapshot(lockGuard, 60 * 60);
ASSERT_VALUE(12, *snap, "test.set1.set1.count1");
- ASSERT_VALUE(12, *snap, "test.set1.set1.loadCount.foo");
- ASSERT_VALUE(24, *snap, "test.set1.set1.loadCount.sum");
ASSERT_VALUE(24, *snap, "test.set1.set1.countSum");
- ASSERT_VALUE(12, *snap, "test.set1.loadSet.foo.count1");
- ASSERT_VALUE(24, *snap, "test.set1.loadSet.foo.countSum");
- ASSERT_VALUE(24, *snap, "test.set1.loadSet.sum.count1");
- ASSERT_VALUE(24, *snap, "test.set1.loadSet.sum.loadCount.foo");
- ASSERT_VALUE(48, *snap, "test.set1.loadSet.sum.loadCount.sum");
- ASSERT_VALUE(48, *snap, "test.set1.loadSet.sum.countSum");
ASSERT_VALUE(1, *snap, "test.set1.set1.average1");
- ASSERT_VALUE(1, *snap, "test.set1.set1.loadAverage.foo");
- ASSERT_VALUE(1, *snap, "test.set1.set1.loadAverage.sum");
ASSERT_VALUE(1, *snap, "test.set1.set1.averageSum");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.foo.average1");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.foo.averageSum");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.sum.average1");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.sum.loadAverage.foo");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.sum.loadAverage.sum");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.sum.averageSum");
// 1 day snapshot
snap = &mm.getMetricSnapshot(lockGuard, 24 * 60 * 60);
ASSERT_VALUE(288, *snap, "test.set1.set1.count1");
- ASSERT_VALUE(288, *snap, "test.set1.set1.loadCount.foo");
- ASSERT_VALUE(576, *snap, "test.set1.set1.loadCount.sum");
ASSERT_VALUE(576, *snap, "test.set1.set1.countSum");
- ASSERT_VALUE(288, *snap, "test.set1.loadSet.foo.count1");
- ASSERT_VALUE(576, *snap, "test.set1.loadSet.foo.countSum");
- ASSERT_VALUE(576, *snap, "test.set1.loadSet.sum.count1");
- ASSERT_VALUE(576, *snap, "test.set1.loadSet.sum.loadCount.foo");
- ASSERT_VALUE(1152, *snap, "test.set1.loadSet.sum.loadCount.sum");
- ASSERT_VALUE(1152, *snap, "test.set1.loadSet.sum.countSum");
ASSERT_VALUE(1, *snap, "test.set1.set1.average1");
- ASSERT_VALUE(1, *snap, "test.set1.set1.loadAverage.foo");
- ASSERT_VALUE(1, *snap, "test.set1.set1.loadAverage.sum");
ASSERT_VALUE(1, *snap, "test.set1.set1.averageSum");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.foo.average1");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.foo.averageSum");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.sum.average1");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.sum.loadAverage.foo");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.sum.loadAverage.sum");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.sum.averageSum");
// total snapshot (2 days currently, not testing weeks)
snap = &mm.getTotalMetricSnapshot(lockGuard);
ASSERT_VALUE(576, *snap, "test.set1.set1.count1");
- ASSERT_VALUE(576, *snap, "test.set1.set1.loadCount.foo");
- ASSERT_VALUE(1152, *snap, "test.set1.set1.loadCount.sum");
ASSERT_VALUE(1152, *snap, "test.set1.set1.countSum");
- ASSERT_VALUE(576, *snap, "test.set1.loadSet.foo.count1");
- ASSERT_VALUE(1152, *snap, "test.set1.loadSet.foo.countSum");
- ASSERT_VALUE(1152, *snap, "test.set1.loadSet.sum.count1");
- ASSERT_VALUE(1152, *snap, "test.set1.loadSet.sum.loadCount.foo");
- ASSERT_VALUE(2304, *snap, "test.set1.loadSet.sum.loadCount.sum");
- ASSERT_VALUE(2304, *snap, "test.set1.loadSet.sum.countSum");
ASSERT_VALUE(1, *snap, "test.set1.set1.average1");
- ASSERT_VALUE(1, *snap, "test.set1.set1.loadAverage.foo");
- ASSERT_VALUE(1, *snap, "test.set1.set1.loadAverage.sum");
ASSERT_VALUE(1, *snap, "test.set1.set1.averageSum");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.foo.average1");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.foo.averageSum");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.sum.average1");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.sum.loadAverage.foo");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.sum.loadAverage.sum");
- ASSERT_VALUE(1, *snap, "test.set1.loadSet.sum.averageSum");
}
}
diff --git a/metrics/src/tests/stresstest.cpp b/metrics/src/tests/stresstest.cpp
index f3e709b4b04..df6641c9798 100644
--- a/metrics/src/tests/stresstest.cpp
+++ b/metrics/src/tests/stresstest.cpp
@@ -1,6 +1,5 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/metrics/loadmetric.hpp>
#include <vespa/metrics/metricmanager.h>
#include <vespa/metrics/metrics.h>
#include <vespa/metrics/summetric.hpp>
@@ -15,42 +14,38 @@ namespace metrics {
namespace {
struct InnerMetricSet : public MetricSet {
- const LoadTypeSet& _loadTypes;
LongCountMetric _count;
LongAverageMetric _value1;
LongAverageMetric _value2;
SumMetric<LongAverageMetric> _valueSum;
- LoadMetric<LongAverageMetric> _load;
- InnerMetricSet(const char* name, const LoadTypeSet& lt, MetricSet* owner = 0);
+ InnerMetricSet(const char* name, MetricSet* owner = 0);
~InnerMetricSet();
MetricSet* clone(std::vector<Metric::UP> &ownerList, CopyType copyType,
MetricSet* owner, bool includeUnused) const override;
};
-InnerMetricSet::InnerMetricSet(const char* name, const LoadTypeSet& lt, MetricSet* owner)
+InnerMetricSet::InnerMetricSet(const char* name, MetricSet* owner)
: MetricSet(name, {}, "", owner),
- _loadTypes(lt),
_count("count", {}, "", this),
_value1("value1", {}, "", this),
_value2("value2", {}, "", this),
- _valueSum("valuesum", {}, "", this),
- _load(lt, LongAverageMetric("load", {}, ""), this)
+ _valueSum("valuesum", {}, "", this)
{
_valueSum.addMetricToSum(_value1);
_valueSum.addMetricToSum(_value2);
}
InnerMetricSet::~InnerMetricSet() = default;
- MetricSet*
- InnerMetricSet::clone(std::vector<Metric::UP> &ownerList, CopyType copyType,
- MetricSet* owner, bool includeUnused) const
+MetricSet*
+InnerMetricSet::clone(std::vector<Metric::UP> &ownerList, CopyType copyType,
+ MetricSet* owner, bool includeUnused) const
{
if (copyType != CLONE) {
return MetricSet::clone(ownerList, copyType, owner, includeUnused);
}
- InnerMetricSet * myset = new InnerMetricSet(getName().c_str(), _loadTypes, owner);
+ InnerMetricSet * myset = new InnerMetricSet(getName().c_str(), owner);
myset->assignValues(*this);
return myset;
}
@@ -60,37 +55,31 @@ struct OuterMetricSet : public MetricSet {
InnerMetricSet _inner2;
SumMetric<InnerMetricSet> _innerSum;
InnerMetricSet _tmp;
- LoadMetric<InnerMetricSet> _load;
- OuterMetricSet(const LoadTypeSet& lt, MetricSet* owner = 0);
+ OuterMetricSet(MetricSet* owner = 0);
~OuterMetricSet();
};
-OuterMetricSet::OuterMetricSet(const LoadTypeSet& lt, MetricSet* owner)
+OuterMetricSet::OuterMetricSet(MetricSet* owner)
: MetricSet("outer", {}, "", owner),
- _inner1("inner1", lt, this),
- _inner2("inner2", lt, this),
+ _inner1("inner1", this),
+ _inner2("inner2", this),
_innerSum("innersum", {}, "", this),
- _tmp("innertmp", lt, 0),
- _load(lt, _tmp, this)
+ _tmp("innertmp", 0)
{
_innerSum.addMetricToSum(_inner1);
_innerSum.addMetricToSum(_inner2);
}
-OuterMetricSet::~OuterMetricSet() { }
+OuterMetricSet::~OuterMetricSet() = default;
struct Hammer : public document::Runnable {
using UP = std::unique_ptr<Hammer>;
OuterMetricSet& _metrics;
- const LoadTypeSet& _loadTypes;
- LoadType _nonexistingLoadType;
- Hammer(OuterMetricSet& metrics, const LoadTypeSet& lt,
- FastOS_ThreadPool& threadPool)
- : _metrics(metrics), _loadTypes(lt),
- _nonexistingLoadType(123, "nonexisting")
+ Hammer(OuterMetricSet& metrics,FastOS_ThreadPool& threadPool)
+ : _metrics(metrics)
{
start(threadPool);
}
@@ -106,8 +95,6 @@ struct Hammer : public document::Runnable {
++i;
setMetrics(i, _metrics._inner1);
setMetrics(i + 3, _metrics._inner2);
- const LoadType& loadType(_loadTypes[i % _loadTypes.size()]);
- setMetrics(i + 5, _metrics._load[loadType]);
}
}
@@ -115,7 +102,6 @@ struct Hammer : public document::Runnable {
set._count.inc(val);
set._value1.addValue(val);
set._value2.addValue(val + 10);
- set._load[_loadTypes[val % _loadTypes.size()]].addValue(val);
}
};
@@ -124,18 +110,13 @@ struct Hammer : public document::Runnable {
TEST(StressTest, test_stress)
{
- LoadTypeSet loadTypes;
- loadTypes.push_back(LoadType(0, "default"));
- loadTypes.push_back(LoadType(2, "foo"));
- loadTypes.push_back(LoadType(1, "bar"));
-
- OuterMetricSet metrics(loadTypes);
+ OuterMetricSet metrics;
LOG(info, "Starting load givers");
FastOS_ThreadPool threadPool(256 * 1024);
std::vector<Hammer::UP> hammers;
for (uint32_t i=0; i<10; ++i) {
- hammers.push_back(std::make_unique<Hammer>(metrics, loadTypes, threadPool));
+ hammers.push_back(std::make_unique<Hammer>(metrics, threadPool));
}
LOG(info, "Waiting to let loadgivers hammer a while");
std::this_thread::sleep_for(5s);
diff --git a/metrics/src/vespa/metrics/CMakeLists.txt b/metrics/src/vespa/metrics/CMakeLists.txt
index 9ac0140c52b..6bb39191791 100644
--- a/metrics/src/vespa/metrics/CMakeLists.txt
+++ b/metrics/src/vespa/metrics/CMakeLists.txt
@@ -4,7 +4,6 @@ vespa_add_library(metrics
countmetric.cpp
countmetricvalues.cpp
jsonwriter.cpp
- loadmetric.cpp
memoryconsumption.cpp
metric.cpp
metricmanager.cpp
diff --git a/metrics/src/vespa/metrics/loadmetric.cpp b/metrics/src/vespa/metrics/loadmetric.cpp
deleted file mode 100644
index 94fc2b9db7c..00000000000
--- a/metrics/src/vespa/metrics/loadmetric.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include "loadmetric.hpp"
-#include "valuemetric.h"
-#include "countmetric.h"
-#include <vespa/vespalib/util/stringfmt.h>
-
-namespace metrics {
-
-vespalib::string
-LoadType::toString() const {
- return vespalib::make_string("%s(%u)", _name.c_str(), _id);
-}
-
-template class LoadMetric<ValueMetric<int64_t, int64_t, false>>;
-template class LoadMetric<ValueMetric<int64_t, int64_t, true>>;
-template class LoadMetric<ValueMetric<double, double, false>>;
-template class LoadMetric<ValueMetric<double, double, true>>;
-template class LoadMetric<CountMetric<uint64_t, true>>;
-
-}
diff --git a/metrics/src/vespa/metrics/loadmetric.h b/metrics/src/vespa/metrics/loadmetric.h
deleted file mode 100644
index 3b0c70440c9..00000000000
--- a/metrics/src/vespa/metrics/loadmetric.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-/**
- * \file loadmetric.h
- * \ingroup metrics
- *
- * \brief Utility class for creating metrics for all load types.
- *
- * To better see how different load types behave in the system we want to log
- * separate metrics for various loadtypes. To make it easy to create and use
- * such metrics, this class is a wrapper class that sets up one metric per load
- * type.
- *
- * In order to make it easy to use load metrics, they are templated on the type,
- * such that you get the correct type out of operator[]. Load metric needs to
- * clone metrics on creation though, so if you want load metrics of a metric set
- * you need to properly implement clone() for that set.
- */
-
-#pragma once
-
-#include "loadtype.h"
-#include "metricset.h"
-#include "summetric.h"
-#include <vespa/vespalib/stllike/hash_map.h>
-
-namespace metrics {
-
-template<typename MetricType>
-class LoadMetric : public MetricSet {
- std::vector<Metric::UP> _ownerList;
- using MetricTypeUP = std::unique_ptr<MetricType>;
- using MetricMap = vespalib::hash_map<uint32_t, MetricTypeUP>;
- MetricMap _metrics;
- SumMetric<MetricType> _sum;
-
-public:
- /**
- * Create a load metric using the given metric as a template to how they
- * shuold look. They will get prefix names based on load types existing.
- */
- LoadMetric(const LoadTypeSet& loadTypes, const MetricType& metric, MetricSet* owner = 0);
-
- /**
- * A load metric implements a copy constructor and a clone functions that
- * clone content, and resetting name/tags/description, just so metric
- * implementors can implement clone() by using regular construction and
- * then assign the values to the new set. (Without screwing up copying as
- * the load metric alters this data in supplied metric)
- */
- LoadMetric(const LoadMetric<MetricType>& other, MetricSet* owner);
- ~LoadMetric();
- MetricSet* clone(std::vector<Metric::UP> &ownerList,
- CopyType copyType, MetricSet* owner,
- bool includeUnused = false) const override;
-
- MetricType& operator[](const LoadType& type) { return getMetric(type); }
- const MetricType& operator[](const LoadType& type) const
- { return const_cast<LoadMetric<MetricType>*>(this)->getMetric(type); }
- MetricType& getMetric(const LoadType& type);
- const MetricMap & getMetricMap() const { return _metrics; }
-
- void addMemoryUsage(MemoryConsumption& mc) const override;
-};
-
-} // metrics
-
diff --git a/metrics/src/vespa/metrics/loadmetric.hpp b/metrics/src/vespa/metrics/loadmetric.hpp
deleted file mode 100644
index 65098662e04..00000000000
--- a/metrics/src/vespa/metrics/loadmetric.hpp
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#pragma once
-
-#include "loadmetric.h"
-#include "memoryconsumption.h"
-#include <vespa/vespalib/stllike/hash_map.hpp>
-#include <cassert>
-
-namespace metrics {
-
-template<typename MetricType>
-LoadMetric<MetricType>::LoadMetric(const LoadTypeSet& loadTypes, const MetricType& metric, MetricSet* owner)
- : MetricSet(metric.getName(), {}, metric.getDescription(), owner),
- _metrics(),
- _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
- // itself, to cut down on size of output when downloading metrics,
- // and since matching tags of parent is just as good as matching
- // them specifically.
- setTags(metric.getTags());
- Tags noTags;
- for (uint32_t i=0; i<loadTypes.size(); ++i) {
- MetricTypeUP copy(dynamic_cast<MetricType*>(metric.clone(_ownerList, CLONE, 0, false)));
- assert(copy.get());
- copy->setName(loadTypes[i].getName());
- copy->setTags(noTags);
- registerMetric(*copy);
- _sum.addMetricToSum(*copy);
- _metrics[loadTypes[i].getId()] = std::move(copy);
- }
- _ownerList.shrink_to_fit();
-}
-
-template<typename MetricType>
-LoadMetric<MetricType>::LoadMetric(const LoadMetric<MetricType>& other, MetricSet* owner)
- : MetricSet(other.getName(), {}, other.getDescription(), owner),
- _metrics(),
- _sum("sum", {{"loadsum"},{"sum"}}, "Sum of all load metrics", this)
-{
- _metrics.resize(2 * other._metrics.size());
- setTags(other.getTags());
- Tags noTags;
- for (const auto & metric : other._metrics) {
- MetricTypeUP copy(dynamic_cast<MetricType*>(metric.second->clone(_ownerList, CLONE, 0, false)));
- assert(copy.get());
- copy->setName(metric.second->getName());
- copy->setTags(noTags);
- registerMetric(*copy);
- _sum.addMetricToSum(*copy);
- _metrics[metric.first] = std::move(copy);
- }
- _ownerList.shrink_to_fit();
-}
-
-template<typename MetricType>
-LoadMetric<MetricType>::~LoadMetric() = default;
-
-template<typename MetricType>
-MetricSet*
-LoadMetric<MetricType>::clone(std::vector<Metric::UP> &ownerList,
- CopyType copyType, MetricSet* owner,
- bool includeUnused) const
-{
- if (copyType == INACTIVE) {
- return MetricSet::clone(ownerList, INACTIVE, owner, includeUnused);
- }
- return new LoadMetric<MetricType>(*this, owner);
-}
-
-template<typename MetricType>
-MetricType&
-LoadMetric<MetricType>::getMetric(const LoadType& type) {
- MetricType* metric;
-
- auto it = _metrics.find(type.getId());
- if (it == _metrics.end()) {
- it = _metrics.find(0u);
- assert(it != _metrics.end()); // Default should always exist
- }
- metric = it->second.get();
- assert(metric);
-
- return *metric;
-}
-
-template<typename MetricType>
-void
-LoadMetric<MetricType>::addMemoryUsage(MemoryConsumption& mc) const {
- ++mc._loadMetricCount;
- mc._loadMetricMeta += (sizeof(Metric::UP) * _ownerList.capacity())
- + (sizeof(typename MetricMap::value_type) * _metrics.capacity());
- _sum.addMemoryUsage(mc);
- mc._loadMetricMeta += sizeof(LoadMetric<MetricType>)
- - sizeof(MetricSet)
- - sizeof(SumMetric<MetricType>);
- MetricSet::addMemoryUsage(mc);
-}
-
-}
-
diff --git a/metrics/src/vespa/metrics/loadtype.h b/metrics/src/vespa/metrics/loadtype.h
deleted file mode 100644
index 7d802ebf456..00000000000
--- a/metrics/src/vespa/metrics/loadtype.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#pragma once
-
-#include <vespa/vespalib/stllike/string.h>
-#include <vector>
-
-namespace metrics {
-
-class LoadType {
-public:
- using string = vespalib::string;
- LoadType(uint32_t id, const string& name) : _id(id), _name(name) {}
-
- uint32_t getId() const { return _id; }
- const string& getName() const { return _name; }
-
- string toString() const;
-private:
- uint32_t _id;
- string _name;
-};
-
-typedef std::vector<LoadType> LoadTypeSet;
-
-}