statsd: support dimension flags, like in plugins
Costa Tsaousis (ktsaou) committed
Dec 20, 2017 at 23:30 UTC
878676ca4a5d9b2e51b5da5253e0f8beb9f93fb5
2 files changed
+17
src/rrd.h
+1
@@ -99,6 +99,7 @@ typedef struct rrdfamily RRDFAMILY;
99
// and may lead to missing information.
100
101
typedef enum rrddim_flags {
102
+ RRDDIM_FLAG_NONE = 0,
103
RRDDIM_FLAG_HIDDEN = 1 << 0, // this dimension will not be offered to callers
104
RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS = 1 << 1 // do not offer RESET or OVERFLOW info to callers
105
} RRDDIM_FLAGS;
src/statsd.c
+16
@@ -175,6 +175,8 @@ typedef struct statsd_app_chart_dimension {
175
176
collected_number multiplier; // the multipler of the dimension
177
collected_number divisor; // the divisor of the dimension
178
+ RRDDIM_FLAGS flags; // the RRDDIM flags for this dimension
179
+
180
STATSD_APP_CHART_DIM_VALUE_TYPE value_type; // which value to use of the source metric
181
182
RRDDIM *rd; // a pointer to the RRDDIM that has been created for this dimension
@@ -977,6 +979,7 @@ static STATSD_APP_CHART_DIM *add_dimension_to_app_chart(
979
, const char *dim_name
980
, collected_number multiplier
981
, collected_number divisor
982
+ , RRDDIM_FLAGS flags
983
, STATSD_APP_CHART_DIM_VALUE_TYPE value_type
984
) {
985
STATSD_APP_CHART_DIM *dim = callocz(sizeof(STATSD_APP_CHART_DIM), 1);
@@ -988,6 +991,7 @@ static STATSD_APP_CHART_DIM *add_dimension_to_app_chart(
991
dim->multiplier = multiplier;
992
dim->divisor = divisor;
993
dim->value_type = value_type;
994
+ dim->flags = flags;
995
996
if(!dim->multiplier)
997
dim->multiplier = 1;
@@ -1209,6 +1213,14 @@ int statsd_readfile(const char *path, const char *filename) {
1213
char *type = words[i++];
1214
char *multipler = words[i++];
1215
char *divisor = words[i++];
1216
+ char *options = words[i++];
1217
+
1218
+ RRDDIM_FLAGS flags = RRDDIM_FLAG_NONE;
1219
+ if(options && *options) {
1220
+ if(strstr(options, "hidden") != NULL) flags |= RRDDIM_FLAG_HIDDEN;
1221
+ if(strstr(options, "noreset") != NULL) flags |= RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS;
1222
+ if(strstr(options, "nooverflow") != NULL) flags |= RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS;
1223
+ }
1224
1225
if(!pattern) {
1226
if(app->dict) {
@@ -1232,6 +1244,7 @@ int statsd_readfile(const char *path, const char *filename) {
1244
, dim_name
1245
, (multipler && *multipler)?str2l(multipler):1
1246
, (divisor && *divisor)?str2l(divisor):1
1247
+ , flags
1248
, string2valuetype(type, line, path, filename)
1249
);
1250
@@ -1779,6 +1792,7 @@ static inline void check_if_metric_is_for_app(STATSD_INDEX *index, STATSD_METRIC
1792
, final_name
1793
, dim->multiplier
1794
, dim->divisor
1795
+ , dim->flags
1796
, dim->value_type
1797
);
1798
@@ -1834,10 +1848,12 @@ static inline RRDDIM *statsd_add_dim_to_app_chart(STATSD_APP *app, STATSD_APP_CH
1848
}
1849
1850
dim->rd = rrddim_add(chart->st, metric, dim->name, dim->multiplier, dim->divisor, dim->algorithm);
1851
+ if(dim->flags != RRDDIM_FLAG_NONE) dim->rd->flags |= dim->flags;
1852
return dim->rd;
1853
}
1854
1855
dim->rd = rrddim_add(chart->st, dim->metric, dim->name, dim->multiplier, dim->divisor, dim->algorithm);
1856
+ if(dim->flags != RRDDIM_FLAG_NONE) dim->rd->flags |= dim->flags;
1857
return dim->rd;
1858
}
1859