Skip to content

Commit

Permalink
encode_opentelemetry: Encode otel payloads if valid contexts are exis…
Browse files Browse the repository at this point in the history
…ting

Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Oct 15, 2024
1 parent 92a16b9 commit ed94318
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/cmt_encode_opentelemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -2396,6 +2396,7 @@ int pack_basic_type(struct cmt_opentelemetry_context *context,
int result;
struct cfl_list *head;
uint64_t now;
int cutoff = CMT_FALSE;

sample_count = 0;
now = cfl_time_now();
Expand Down Expand Up @@ -2471,10 +2472,10 @@ int pack_basic_type(struct cmt_opentelemetry_context *context,
if (context->use_cutoff == CMT_TRUE &&
check_staled_timestamp(&map->metric, now,
context->cutoff_threshold)) {
destroy_metric(metric);

/* Skip processing metrics which are staled over the threshold */
return CMT_ENCODE_OPENTELEMETRY_CUTOFF_ERROR;
cutoff = CMT_TRUE;
continue;
}

result = append_sample_to_metric(context,
Expand Down Expand Up @@ -2506,6 +2507,10 @@ int pack_basic_type(struct cmt_opentelemetry_context *context,

(*metric_index)++;

if (cutoff == CMT_TRUE) {
return CMT_ENCODE_OPENTELEMETRY_CUTOFF_ERROR;
}

return result;
}

Expand Down Expand Up @@ -2631,10 +2636,9 @@ cfl_sds_t cmt_encode_opentelemetry_create_with_cutoff_opts(struct cmt *cmt,
}
}

if (result == CMT_ENCODE_OPENTELEMETRY_SUCCESS) {
if (metric_index > 0) {
buf = render_opentelemetry_context_to_sds(context);
}
else if (result == CMT_ENCODE_OPENTELEMETRY_CUTOFF_ERROR) {
} else {
buf = NULL;
}

Expand Down

0 comments on commit ed94318

Please sign in to comment.