Skip to content

Commit 8916ac7

Browse files
committed
out_opentelemetry: remove strict check on severityText value
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 362ca1f commit 8916ac7

File tree

1 file changed

+3
-30
lines changed

1 file changed

+3
-30
lines changed

plugins/out_opentelemetry/opentelemetry_logs.c

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
#include <fluent-bit/flb_ra_key.h>
2828
#include <fluent-bit/flb_gzip.h>
2929

30-
31-
//#include <cfl/cfl.h>
3230
#include <fluent-otel-proto/fluent-otel.h>
3331

3432
#include "opentelemetry.h"
@@ -81,26 +79,6 @@ static int hex_to_id(char *str, int len, unsigned char *out_buf, int out_size)
8179
return 0;
8280
}
8381

84-
/* https://opentelemetry.io/docs/specs/otel/logs/data-model/#field-severitynumber */
85-
static int is_valid_severity_text(const char *str, size_t str_len)
86-
{
87-
if (str_len == 5) {
88-
if (strncmp("TRACE", str, 5) == 0 ||
89-
strncmp("DEBUG", str, 5) == 0 ||
90-
strncmp("ERROR", str, 5) == 0 ||
91-
strncmp("FATAL", str, 5) == 0) {
92-
return FLB_TRUE;
93-
}
94-
}
95-
else if (str_len == 4) {
96-
if (strncmp("INFO", str, 4) == 0||
97-
strncmp("WARN", str, 4) == 0) {
98-
return FLB_TRUE;
99-
}
100-
}
101-
return FLB_FALSE;
102-
}
103-
10482
/* https://opentelemetry.io/docs/specs/otel/logs/data-model/#field-severitynumber */
10583
static int is_valid_severity_number(uint64_t val)
10684
{
@@ -110,7 +88,6 @@ static int is_valid_severity_number(uint64_t val)
11088
return FLB_FALSE;
11189
}
11290

113-
11491
/*
11592
* From a group record, extract it metadata and validate if it has a valid OTLP schema and check that
11693
* resource_id is set. On success it returns the resource_id, otherwise it returns -1.
@@ -495,9 +472,7 @@ static int append_v1_logs_metadata_and_fields(struct opentelemetry_context *ctx,
495472
/* SeverityText */
496473
ra_val = flb_ra_get_value_object(ctx->ra_log_meta_otlp_severity_text, *event->metadata);
497474
if (ra_val != NULL) {
498-
if (ra_val->o.type == MSGPACK_OBJECT_STR &&
499-
is_valid_severity_text(ra_val->o.via.str.ptr, ra_val->o.via.str.size)) {
500-
475+
if (ra_val->o.type == MSGPACK_OBJECT_STR) {
501476
log_record->severity_text = flb_calloc(1, ra_val->o.via.str.size + 1);
502477
if (log_record->severity_text) {
503478
strncpy(log_record->severity_text, ra_val->o.via.str.ptr, ra_val->o.via.str.size);
@@ -510,8 +485,7 @@ static int append_v1_logs_metadata_and_fields(struct opentelemetry_context *ctx,
510485
if (!severity_text_set && ctx->ra_severity_text_metadata) {
511486
ra_val = flb_ra_get_value_object(ctx->ra_severity_text_metadata, *event->metadata);
512487
if (ra_val != NULL) {
513-
if (ra_val->o.type == MSGPACK_OBJECT_STR &&
514-
is_valid_severity_text(ra_val->o.via.str.ptr, ra_val->o.via.str.size)) {
488+
if (ra_val->o.type == MSGPACK_OBJECT_STR) {
515489
log_record->severity_text = flb_calloc(1, ra_val->o.via.str.size + 1);
516490
if (log_record->severity_text) {
517491
strncpy(log_record->severity_text, ra_val->o.via.str.ptr, ra_val->o.via.str.size);
@@ -525,8 +499,7 @@ static int append_v1_logs_metadata_and_fields(struct opentelemetry_context *ctx,
525499
if (!severity_text_set && ctx->ra_severity_text_message) {
526500
ra_val = flb_ra_get_value_object(ctx->ra_severity_text_message, *event->body);
527501
if (ra_val != NULL) {
528-
if (ra_val->o.type == MSGPACK_OBJECT_STR &&
529-
is_valid_severity_text(ra_val->o.via.str.ptr, ra_val->o.via.str.size)) {
502+
if (ra_val->o.type == MSGPACK_OBJECT_STR) {
530503
log_record->severity_text = flb_calloc(1, ra_val->o.via.str.size + 1);
531504
if (log_record->severity_text) {
532505
strncpy(log_record->severity_text, ra_val->o.via.str.ptr, ra_val->o.via.str.size);

0 commit comments

Comments
 (0)