Code

store: Include in metric JSON whether access to time-series is available.
authorSebastian Harl <sh@tokkee.org>
Sat, 22 Nov 2014 10:24:53 +0000 (11:24 +0100)
committerSebastian Harl <sh@tokkee.org>
Sat, 22 Nov 2014 10:24:53 +0000 (11:24 +0100)
… based on whether a time-series store is configured for the metric.

src/core/store_json.c
t/unit/core/store_json_test.c

index 8ec717515b69c7e480f0f46c289af689004c4a03..f5be74543f32ed8bbee35b2cff6f95dba828d2e1 100644 (file)
@@ -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),
index d7fad58c8d9793567f476810bd763c5a4516f413..091a48b5519b44663d5493813780fc469fbe5e9d 100644 (file)
@@ -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\": []}"
                                        "]}"