Skip to content

Commit a988291

Browse files
committed
out_splunk: when packing OTel metadata, include resource attributes
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 5233aad commit a988291

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

plugins/out_splunk/splunk.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ static int pack_otel_data(struct flb_splunk *ctx,
164164
msgpack_object *source_map;
165165
char schema[8];
166166
int result;
167+
int source_map_resource_attributes = FLB_FALSE;
167168
struct flb_mp_map_header mh_tmp;
168169
msgpack_object *value;
169170
size_t index;
@@ -187,6 +188,7 @@ static int pack_otel_data(struct flb_splunk *ctx,
187188
source_map = local_msgpack_map_lookup(source_map, "attributes");
188189

189190
if (source_map != NULL) {
191+
source_map_resource_attributes = FLB_TRUE;
190192
value = local_msgpack_map_lookup(source_map,
191193
"host.name");
192194

@@ -209,6 +211,15 @@ static int pack_otel_data(struct flb_splunk *ctx,
209211

210212
flb_mp_map_header_init(&mh_tmp, mp_pck);
211213

214+
/* check if we have resource attributes to pack */
215+
if (source_map_resource_attributes == FLB_TRUE) {
216+
for (index = 0; index < source_map->via.map.size ; index++) {
217+
flb_mp_map_header_append(&mh_tmp);
218+
msgpack_pack_object(mp_pck, source_map->via.map.ptr[index].key);
219+
msgpack_pack_object(mp_pck, source_map->via.map.ptr[index].val);
220+
}
221+
}
222+
212223
source_map = local_msgpack_map_lookup(record_attributes, "otlp");
213224

214225
if (source_map != NULL) {
@@ -457,7 +468,6 @@ static int pack_map(struct flb_splunk *ctx, msgpack_packer *mp_pck,
457468
record_attributes);
458469

459470
if (result != 0) {
460-
printf("ERROR %d\n", result);
461471
return -1;
462472
}
463473

0 commit comments

Comments
 (0)