summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bfa038b)
raw | patch | inline | side by side (parent: bfa038b)
author | Aleksei Zakharov <zaharov@selectel.ru> | |
Wed, 4 Oct 2017 08:12:23 +0000 (11:12 +0300) | ||
committer | Aleksei Zakharov <zaharov@selectel.ru> | |
Wed, 4 Oct 2017 08:12:31 +0000 (11:12 +0300) |
This patch is not backward compatible with previous ceph versions.
src/ceph.c | patch | blob | history |
diff --git a/src/ceph.c b/src/ceph.c
index c2284cb3baa70d26ad8f7d4a9e09a031158a1929..59ddca210e9f804b5306df85b9bc3ebcb1fd6c5f 100644 (file)
--- a/src/ceph.c
+++ b/src/ceph.c
/* Special case for latency metrics. */
if ((strcmp("avgcount", state->key) == 0) ||
- (strcmp("sum", state->key) == 0)) {
+ (strcmp("sum", state->key) == 0) ||
+ (strcmp("avgtime",state->key) == 0)) {
latency_type = 1;
/* depth >= 2 => (stack[-1] != NULL && stack[-2] != NULL) */
// return after saving avgcount - don't dispatch value
// until latency calculation
return 0;
- } else {
- double sum, result;
- sscanf(val, "%lf", &sum);
-
+ } else if (vtmp->avgcount_exists == 0) {
if (vtmp->avgcount == 0) {
vtmp->avgcount = 1;
}
-
- /** User wants latency values as long run avg */
+ vtmp->avgcount_exists = 1;
+ // user wants latency values as long run avg
+ // skip this step
if (long_run_latency_avg) {
- result = (sum / vtmp->avgcount);
- } else {
- result = get_last_avg(vtmp->d, ds_name, vtmp->latency_index, sum,
- vtmp->avgcount);
- if (result == -ENOMEM) {
- return -ENOMEM;
- }
+ return 0;
+ }
+ double sum, result;
+ sscanf(val, "%lf", &sum);
+ result = get_last_avg(vtmp->d, ds_name, vtmp->latency_index, sum,
+ vtmp->avgcount);
+ if (result == -ENOMEM) {
+ return -ENOMEM;
}
-
uv.gauge = result;
+ vtmp->latency_index = (vtmp->latency_index + 1);
+ } else if (vtmp->avgcount_exists == 1 ) {
vtmp->avgcount_exists = -1;
+ // skip this step if no need in long run latency
+ if (!long_run_latency_avg) {
+ return 0;
+ }
+ double result;
+ sscanf(val, "%lf", &result);
+ uv.gauge = result;
vtmp->latency_index = (vtmp->latency_index + 1);
}
break;