From: Sebastian Harl Date: Sat, 22 Nov 2014 10:24:53 +0000 (+0100) Subject: store: Include in metric JSON whether access to time-series is available. X-Git-Tag: sysdb-0.7.0~126 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=547d580b6de9505a93a2ae1f4c5fec834ae3b8e9;p=sysdb.git store: Include in metric JSON whether access to time-series is available. … based on whether a time-series store is configured for the metric. --- diff --git a/src/core/store_json.c b/src/core/store_json.c index 8ec7175..f5be745 100644 --- a/src/core/store_json.c +++ b/src/core/store_json.c @@ -132,6 +132,12 @@ json_emit(sdb_store_json_formatter_t *f, sdb_store_obj_t *obj) else sdb_strbuf_append(f->buf, "\"value\": %s, ", tmp); } + else if (obj->type == SDB_METRIC) { + if (METRIC(obj)->store.type != NULL) + sdb_strbuf_append(f->buf, "\"timeseries\": true, "); + else + sdb_strbuf_append(f->buf, "\"timeseries\": false, "); + } /* TODO: make time and interval formats configurable */ if (! sdb_strftime(time_str, sizeof(time_str), diff --git a/t/unit/core/store_json_test.c b/t/unit/core/store_json_test.c index d7fad58..091a48b 100644 --- a/t/unit/core/store_json_test.c +++ b/t/unit/core/store_json_test.c @@ -152,6 +152,7 @@ START_TEST(test_store_tojson) "], " "\"metrics\": [" "{\"name\": \"m1\", " + "\"timeseries\": false, " "\"last_update\": \"1970-01-01 00:00:00 +0000\", " "\"update_interval\": \"0s\", \"backends\": [], " "\"attributes\": [" @@ -160,6 +161,7 @@ START_TEST(test_store_tojson) "\"update_interval\": \"0s\", \"backends\": []}" "]}," "{\"name\": \"m2\", " + "\"timeseries\": false, " "\"last_update\": \"1970-01-01 00:00:00 +0000\", " "\"update_interval\": \"0s\", \"backends\": []}" "]}," @@ -167,6 +169,7 @@ START_TEST(test_store_tojson) "\"update_interval\": \"0s\", \"backends\": [], " "\"metrics\": [" "{\"name\": \"m1\", " + "\"timeseries\": false, " "\"last_update\": \"1970-01-01 00:00:00 +0000\", " "\"update_interval\": \"0s\", \"backends\": []}" "], " @@ -232,6 +235,7 @@ START_TEST(test_store_tojson) "], " "\"metrics\": [" "{\"name\": \"m2\", " + "\"timeseries\": false, " "\"last_update\": \"1970-01-01 00:00:00 +0000\", " "\"update_interval\": \"0s\", \"backends\": []}" "]}" @@ -312,6 +316,7 @@ START_TEST(test_store_tojson) "\"update_interval\": \"0s\", \"backends\": [], " "\"metrics\": [" "{\"name\": \"m1\", " + "\"timeseries\": false, " "\"last_update\": \"1970-01-01 00:00:00 +0000\", " "\"update_interval\": \"0s\", \"backends\": [], " "\"attributes\": [" @@ -320,6 +325,7 @@ START_TEST(test_store_tojson) "\"update_interval\": \"0s\", \"backends\": []}" "]}," "{\"name\": \"m2\", " + "\"timeseries\": false, " "\"last_update\": \"1970-01-01 00:00:00 +0000\", " "\"update_interval\": \"0s\", \"backends\": []}" "]}," @@ -327,6 +333,7 @@ START_TEST(test_store_tojson) "\"update_interval\": \"0s\", \"backends\": [], " "\"metrics\": [" "{\"name\": \"m1\", " + "\"timeseries\": false, " "\"last_update\": \"1970-01-01 00:00:00 +0000\", " "\"update_interval\": \"0s\", \"backends\": []}" "]}" @@ -338,9 +345,11 @@ START_TEST(test_store_tojson) "\"update_interval\": \"0s\", \"backends\": [], " "\"metrics\": [" "{\"name\": \"m1\", " + "\"timeseries\": false, " "\"last_update\": \"1970-01-01 00:00:00 +0000\", " "\"update_interval\": \"0s\", \"backends\": []}," "{\"name\": \"m2\", " + "\"timeseries\": false, " "\"last_update\": \"1970-01-01 00:00:00 +0000\", " "\"update_interval\": \"0s\", \"backends\": []}" "]}," @@ -348,6 +357,7 @@ START_TEST(test_store_tojson) "\"update_interval\": \"0s\", \"backends\": [], " "\"metrics\": [" "{\"name\": \"m1\", " + "\"timeseries\": false, " "\"last_update\": \"1970-01-01 00:00:00 +0000\", " "\"update_interval\": \"0s\", \"backends\": []}" "]}" @@ -360,6 +370,7 @@ START_TEST(test_store_tojson) "\"update_interval\": \"0s\", \"backends\": [], " "\"metrics\": [" "{\"name\": \"m2\", " + "\"timeseries\": false, " "\"last_update\": \"1970-01-01 00:00:00 +0000\", " "\"update_interval\": \"0s\", \"backends\": []}" "]}"