diff options
author | HÃ¥vard Pettersen <havardpe@gmail.com> | 2016-10-13 09:07:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-13 09:07:58 +0200 |
commit | f599b3928904a96bb85b5ae37d26416ea390f207 (patch) | |
tree | fbbd4c56699482f8c660950052cb62d3ff9072cf /staging_vespalib | |
parent | 203aaeda425761861d75cbcb0ca446bd569e040d (diff) | |
parent | e625a9029c917d31d59b818ff802313a6c54cbeb (diff) |
Merge pull request #856 from yahoo/vekterli/use-statereporter-metric-consumer-by-default-in-state-api
Use a metric consumer of "statereporter" by default
Diffstat (limited to 'staging_vespalib')
-rw-r--r-- | staging_vespalib/src/tests/state_server/state_server_test.cpp | 11 | ||||
-rw-r--r-- | staging_vespalib/src/vespa/vespalib/net/state_api.cpp | 4 |
2 files changed, 12 insertions, 3 deletions
diff --git a/staging_vespalib/src/tests/state_server/state_server_test.cpp b/staging_vespalib/src/tests/state_server/state_server_test.cpp index 79236523694..b1593d2c70e 100644 --- a/staging_vespalib/src/tests/state_server/state_server_test.cpp +++ b/staging_vespalib/src/tests/state_server/state_server_test.cpp @@ -322,15 +322,22 @@ struct EchoConsumer : MetricsProducer { } }; +TEST_FFFF("require that empty metrics consumer defaults to 'statereporter'", + SimpleHealthProducer(), EchoConsumer(), SimpleComponentConfigProducer(), + StateApi(f1, f2, f3)) +{ + std::map<vespalib::string,vespalib::string> my_params; + EXPECT_EQUAL("{\"status\":{\"code\":\"up\"},\"metrics\":[\"statereporter\"]}", f4.get(host_tag, metrics_path, empty_params)); + EXPECT_EQUAL("[\"statereporter\"]", f4.get(host_tag, total_metrics_path, empty_params)); +} + TEST_FFFF("require that metrics consumer is passed correctly", SimpleHealthProducer(), EchoConsumer(), SimpleComponentConfigProducer(), StateApi(f1, f2, f3)) { std::map<vespalib::string,vespalib::string> my_params; my_params["consumer"] = "ME"; - EXPECT_EQUAL("{\"status\":{\"code\":\"up\"},\"metrics\":[\"\"]}", f4.get(host_tag, metrics_path, empty_params)); EXPECT_EQUAL("{\"status\":{\"code\":\"up\"},\"metrics\":[\"ME\"]}", f4.get(host_tag, metrics_path, my_params)); - EXPECT_EQUAL("[\"\"]", f4.get(host_tag, total_metrics_path, empty_params)); EXPECT_EQUAL("[\"ME\"]", f4.get(host_tag, total_metrics_path, my_params)); } diff --git a/staging_vespalib/src/vespa/vespalib/net/state_api.cpp b/staging_vespalib/src/vespa/vespalib/net/state_api.cpp index 50a8a969e9c..1885de0f99b 100644 --- a/staging_vespalib/src/vespa/vespalib/net/state_api.cpp +++ b/staging_vespalib/src/vespa/vespalib/net/state_api.cpp @@ -56,7 +56,9 @@ void build_health_status(JSONStringer &json, const HealthProducer &healthProduce vespalib::string get_consumer(const std::map<vespalib::string,vespalib::string> ¶ms) { auto consumer_lookup = params.find("consumer"); if (consumer_lookup == params.end()) { - return ""; + // Using a 'statereporter' consumer removes many uninteresting per-thread + // metrics but retains their aggregates. + return "statereporter"; } return consumer_lookup->second; } |