Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prometheus_remote_write: Fix cutoff logic. #225

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/cmt_encode_prometheus_remote_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,11 @@ int pack_basic_type(struct cmt_prometheus_remote_write_context *context,
int result;
struct cfl_list *head;
uint64_t now;
int cutoff;

context->sequence_number++;
add_metadata = CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_ADD_METADATA;
cutoff = CMT_FALSE;

now = cfl_time_now();

Expand All @@ -689,7 +691,8 @@ int pack_basic_type(struct cmt_prometheus_remote_write_context *context,
if (check_staled_timestamp(metric, now,
CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_CUTOFF_THRESHOLD)) {
/* Skip processing metrics which are staled over over the threshold */
return CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_CUTOFF_ERROR;
cutoff = CMT_TRUE;
continue;
}

result = pack_basic_metric_sample(context, map, metric, add_metadata);
Expand All @@ -703,7 +706,9 @@ int pack_basic_type(struct cmt_prometheus_remote_write_context *context,
}
}

return CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_SUCCESS;
return cutoff == CMT_TRUE ?
CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_CUTOFF_ERROR :
CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_SUCCESS;
}

int pack_complex_metric_sample(struct cmt_prometheus_remote_write_context *context,
Expand Down Expand Up @@ -1111,7 +1116,8 @@ cfl_sds_t cmt_encode_prometheus_remote_write_create(struct cmt *cmt)
}
}

if (result == CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_SUCCESS) {
if (result == CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_SUCCESS ||
result == CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_CUTOFF_ERROR) {
/* Gauges */
cfl_list_foreach(head, &cmt->gauges) {
gauge = cfl_list_entry(head, struct cmt_gauge, _head);
Expand All @@ -1127,7 +1133,8 @@ cfl_sds_t cmt_encode_prometheus_remote_write_create(struct cmt *cmt)
}
}

if (result == CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_SUCCESS) {
if (result == CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_SUCCESS ||
result == CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_CUTOFF_ERROR) {
/* Untyped */
cfl_list_foreach(head, &cmt->untypeds) {
untyped = cfl_list_entry(head, struct cmt_untyped, _head);
Expand All @@ -1139,7 +1146,8 @@ cfl_sds_t cmt_encode_prometheus_remote_write_create(struct cmt *cmt)
}
}

if (result == CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_SUCCESS) {
if (result == CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_SUCCESS ||
result == CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_CUTOFF_ERROR) {
/* Summaries */
cfl_list_foreach(head, &cmt->summaries) {
summary = cfl_list_entry(head, struct cmt_summary, _head);
Expand All @@ -1155,7 +1163,8 @@ cfl_sds_t cmt_encode_prometheus_remote_write_create(struct cmt *cmt)
}
}

if (result == CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_SUCCESS) {
if (result == CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_SUCCESS ||
result == CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_CUTOFF_ERROR) {
/* Histograms */
cfl_list_foreach(head, &cmt->histograms) {
histogram = cfl_list_entry(head, struct cmt_histogram, _head);
Expand Down
Loading