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

out_splunk: do not fail on Opentelemetry packing if some Log fields are missing (backport v3.2) #10154

Open
wants to merge 1 commit into
base: 3.2
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
19 changes: 2 additions & 17 deletions plugins/out_splunk/splunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,32 +183,23 @@ static int pack_otel_data(struct flb_splunk *ctx,
}

source_map = local_msgpack_map_lookup(group_attributes, "resource");

if (source_map != NULL) {
source_map = local_msgpack_map_lookup(source_map, "attributes");

if (source_map != NULL) {
source_map_resource_attributes = FLB_TRUE;
value = local_msgpack_map_lookup(source_map,
"host.name");
value = local_msgpack_map_lookup(source_map, "host.name");

if (value != NULL) {
flb_mp_map_header_append(mh_pck);

local_msgpack_pack_cstr(mp_pck, "host");

msgpack_pack_object(mp_pck, *value);
}
else {
return -2;
}
}
}

flb_mp_map_header_append(mh_pck);

local_msgpack_pack_cstr(mp_pck, "fields");

flb_mp_map_header_init(&mh_tmp, mp_pck);

/* check if we have resource attributes to pack */
Expand All @@ -235,24 +226,17 @@ static int pack_otel_data(struct flb_splunk *ctx,

msgpack_pack_object(mp_pck, *value);
}
else {
return -2;
}

value = local_msgpack_map_lookup(source_map,
"severity_text");

if (value != NULL &&
value->type == MSGPACK_OBJECT_STR) {
flb_mp_map_header_append(&mh_tmp);

local_msgpack_pack_cstr(mp_pck, "otel.log.severity.text");

msgpack_pack_object(mp_pck, *value);
}
else {
return -3;
}

source_map = local_msgpack_map_lookup(source_map, "attributes");

Expand Down Expand Up @@ -468,6 +452,7 @@ static int pack_map(struct flb_splunk *ctx, msgpack_packer *mp_pck,
record_attributes);

if (result != 0) {
flb_plg_error(ctx->ins, "failed to pack otel data");
return -1;
}

Expand Down
Loading