Skip to content

Commit

Permalink
decode: remove quantile limit, re #167.
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Whelan <[email protected]>
  • Loading branch information
pwhelan authored and edsiper committed Nov 7, 2022
1 parent 46cd392 commit 1d32567
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
3 changes: 2 additions & 1 deletion include/cmetrics/cmt_decode_msgpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ struct cmt_msgpack_decode_context {
size_t bucket_count;
double *quantile_list;
size_t quantile_count;
uint64_t summary_quantiles[5];
uint64_t *summary_quantiles;
size_t summary_quantiles_count;
int aggregation_type;
};

Expand Down
1 change: 1 addition & 0 deletions include/cmetrics/cmt_metric.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct cmt_metric {
/* summary */
int sum_quantiles_set; /* specify if quantive values has been set */
uint64_t *sum_quantiles; /* 0, 0.25, 0.5, 0.75 and 1 */
size_t sum_quantiles_count;
uint64_t sum_count;
uint64_t sum_sum;

Expand Down
13 changes: 1 addition & 12 deletions src/cmt_decode_msgpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
#include <cmetrics/cmt_variant_utils.h>
#include <cmetrics/cmt_mpack_utils.h>

#ifndef CMT_SUMMARY_QUANTILE_ELEMENT_LIMIT
#define CMT_SUMMARY_QUANTILE_ELEMENT_LIMIT 5
#endif

static int create_counter_instance(struct cmt_map *map)
{
Expand Down Expand Up @@ -442,11 +439,6 @@ static int unpack_summary_quantile(mpack_reader_t *reader, size_t index, void *c
}

decode_context = (struct cmt_msgpack_decode_context *) context;

if (index >= CMT_SUMMARY_QUANTILE_ELEMENT_LIMIT) {
return CMT_DECODE_MSGPACK_INVALID_ARGUMENT_ERROR;
}

return cmt_mpack_consume_uint_tag(reader, &decode_context->metric->sum_quantiles[index]);
}

Expand Down Expand Up @@ -677,6 +669,7 @@ static int unpack_metric(mpack_reader_t *reader,

return CMT_DECODE_MSGPACK_ALLOCATION_ERROR;
}
metric->sum_quantiles_count = summary->quantiles_count;
}

cfl_list_init(&metric->labels);
Expand Down Expand Up @@ -1000,10 +993,6 @@ static int unpack_basic_type_meta(mpack_reader_t *reader, size_t index, void *co

decode_context->quantile_list = NULL;
decode_context->quantile_count = 0;

if (summary->quantiles == NULL) {
result = CMT_DECODE_MSGPACK_ALLOCATION_ERROR;
}
}
else if(decode_context->map->type == CMT_COUNTER) {
counter = (struct counter *) decode_context->map->parent;
Expand Down
1 change: 1 addition & 0 deletions src/cmt_decode_opentelemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ static int decode_summary_data_point(struct cmt *cmt,
}

sample->sum_quantiles_set = CMT_TRUE;
sample->sum_quantiles_count = data_point->n_quantile_values;
}

for (index = 0 ;
Expand Down
3 changes: 2 additions & 1 deletion src/cmt_summary.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ double cmt_summary_quantile_get_value(struct cmt_metric *metric, int quantile_id
{
uint64_t val;

if (quantile_id < 0 || quantile_id > 5) {
if (quantile_id < 0 /*|| quantile_id > metric->sum_quantiles_count*/) {
return 0;
}

Expand Down Expand Up @@ -285,6 +285,7 @@ int cmt_summary_set_default(struct cmt_summary *summary,
cmt_errno();
return -1;
}
metric->sum_quantiles_count = summary->quantiles_count;
}

/* set quantile values */
Expand Down

0 comments on commit 1d32567

Please sign in to comment.