Skip to content

Commit

Permalink
store: Include in metric JSON whether access to time-series is availa…
Browse files Browse the repository at this point in the history
…ble.

… based on whether a time-series store is configured for the metric.
  • Loading branch information
tokkee committed Nov 22, 2014
1 parent 1fc4fcd commit 547d580
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/store_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
11 changes: 11 additions & 0 deletions t/unit/core/store_json_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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\": ["
Expand All @@ -160,13 +161,15 @@ 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\": []}"
"]},"
"{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"metrics\": ["
"{\"name\": \"m1\", "
"\"timeseries\": false, "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"], "
Expand Down Expand Up @@ -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\": []}"
"]}"
Expand Down Expand Up @@ -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\": ["
Expand All @@ -320,13 +325,15 @@ 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\": []}"
"]},"
"{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"metrics\": ["
"{\"name\": \"m1\", "
"\"timeseries\": false, "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"]}"
Expand All @@ -338,16 +345,19 @@ 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\": []}"
"]},"
"{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"metrics\": ["
"{\"name\": \"m1\", "
"\"timeseries\": false, "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"]}"
Expand All @@ -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\": []}"
"]}"
Expand Down

0 comments on commit 547d580

Please sign in to comment.