Skip to content
Merged
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
28 changes: 26 additions & 2 deletions plugins/in_opentelemetry/opentelemetry_prot.c
Original file line number Diff line number Diff line change
Expand Up @@ -2175,6 +2175,12 @@ static int process_payload_metrics_ng(struct flb_opentelemetry *ctx,

offset = 0;

if (request->content_type == NULL) {
flb_error("[otel] content type missing");

return -1;
}

if (strcasecmp(request->content_type, "application/grpc") == 0) {
if (cfl_sds_len(request->body) < 5) {
return -1;
Expand All @@ -2185,12 +2191,18 @@ static int process_payload_metrics_ng(struct flb_opentelemetry *ctx,
cfl_sds_len(request->body) - 5,
&offset);
}
else {
else if (strcasecmp(request->content_type, "application/x-protobuf") == 0 ||
strcasecmp(request->content_type, "application/json") == 0) {
result = cmt_decode_opentelemetry_create(&decoded_contexts,
request->body,
cfl_sds_len(request->body),
&offset);
}
else {
flb_plg_error(ctx->ins, "Unsupported content type %s", request->content_type);

return -1;
}

if (result == CMT_DECODE_OPENTELEMETRY_SUCCESS) {
cfl_list_foreach(iterator, &decoded_contexts) {
Expand Down Expand Up @@ -2221,6 +2233,12 @@ static int process_payload_traces_proto_ng(struct flb_opentelemetry *ctx,

offset = 0;

if (request->content_type == NULL) {
flb_error("[otel] content type missing");

return -1;
}

if (strcasecmp(request->content_type, "application/grpc") == 0) {
if (cfl_sds_len(request->body) < 5) {
return -1;
Expand All @@ -2231,12 +2249,18 @@ static int process_payload_traces_proto_ng(struct flb_opentelemetry *ctx,
cfl_sds_len(request->body) - 5,
&offset);
}
else {
else if (strcasecmp(request->content_type, "application/x-protobuf") == 0 ||
strcasecmp(request->content_type, "application/json") == 0) {
result = ctr_decode_opentelemetry_create(&decoded_context,
request->body,
cfl_sds_len(request->body),
&offset);
}
else {
flb_plg_error(ctx->ins, "Unsupported content type %s", request->content_type);

return -1;
}

if (result == 0) {
result = flb_input_trace_append(ctx->ins, NULL, 0, decoded_context);
Expand Down