Skip to content

Commit

Permalink
in_event_type: use proper API to generate id
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <eduardo@calyptia.com>
  • Loading branch information
edsiper committed Oct 21, 2022
1 parent 82a18f3 commit 1f0d963
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions plugins/in_event_type/event_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ static int send_traces(struct flb_input_instance *ins)
ctr_scope_span_set_instrumentation_scope(scope_span, instrumentation_scope);

/* generate a random trace_id */
trace_id = ctr_id_create_random();
trace_id = ctr_id_create_random(CTR_ID_OTEL_TRACE_SIZE);

/* generate a random ID for the new span */
span_id = create_random_span_id();
span_id = ctr_id_create_random(CTR_ID_OTEL_SPAN_SIZE);

/* Create a root span */
span_root = ctr_span_create(ctx, scope_span, "main", NULL);
Expand Down Expand Up @@ -314,8 +314,8 @@ static int send_traces(struct flb_input_instance *ins)
ctr_span_kind_set(span_child, CTRACE_SPAN_CLIENT);

/* create a Link (no valid IDs of course) */
trace_id = ctr_id_create_random();
span_id = create_random_span_id();
trace_id = ctr_id_create_random(CTR_ID_OTEL_TRACE_SIZE);
span_id = ctr_id_create_random(CTR_ID_OTEL_SPAN_SIZE);

link = ctr_link_create_with_cid(span_child, trace_id, span_id);
ctr_link_set_trace_state(link, "aaabbbccc");
Expand Down Expand Up @@ -344,12 +344,15 @@ static int cb_collector_time(struct flb_input_instance *ins,

if (ctx->type == FLB_EVENT_TYPE_LOGS) {
ret = send_logs(ins);
flb_plg_debug(ins, "logs, ret=%i", ret);
}
else if (ctx->type == FLB_EVENT_TYPE_METRICS) {
ret = send_metrics(ins);
flb_plg_debug(ins, "metrics, ret=%i", ret);
}
else if (ctx->type == FLB_EVENT_TYPE_TRACES) {
ret = send_traces(ins);
flb_plg_debug(ins, "traces, ret=%i", ret);
}

flb_plg_info(ins, "[OK] collector_time");
Expand All @@ -360,12 +363,9 @@ static int cb_collector_time(struct flb_input_instance *ins,
static int cb_event_type_init(struct flb_input_instance *ins,
struct flb_config *config, void *data)
{
int fd;
int ret;
char *tmp;
struct unit_test *ut;
struct event_type *ctx = NULL;
struct flb_upstream *upstream;

ctx = flb_calloc(1, sizeof(struct event_type));
if (!ctx) {
Expand All @@ -380,7 +380,7 @@ static int cb_event_type_init(struct flb_input_instance *ins,


ctx->type = FLB_EVENT_TYPE_LOGS;
tmp = flb_input_get_property("type", ins);
tmp = (char *) flb_input_get_property("type", ins);
if (tmp) {
if (strcasecmp(tmp, "logs") == 0) {
ctx->type = FLB_EVENT_TYPE_LOGS;
Expand Down Expand Up @@ -412,8 +412,6 @@ static int cb_event_type_init(struct flb_input_instance *ins,

static int cb_event_type_exit(void *data, struct flb_config *config)
{
int i;
int failed = FLB_FALSE;
struct event_type *ctx = data;

flb_free(ctx);
Expand Down

0 comments on commit 1f0d963

Please sign in to comment.