@@ -764,12 +764,14 @@ static int process_json_payload_resource_logs_entry(struct flb_opentelemetry *ct
764764 }
765765
766766 /* resource dropped_attributers_count */
767- result = find_map_entry_by_key (resource , "droppedAttributesCount" , 0 , FLB_TRUE );
768- if (result >= 0 ) {
769- obj = resource -> ptr [result ].val ;
770- flb_log_event_encoder_append_body_values (encoder ,
771- FLB_LOG_EVENT_CSTRING_VALUE ("dropped_attributes_count" ),
772- FLB_LOG_EVENT_MSGPACK_OBJECT_VALUE (& obj ));
767+ if (resource ) {
768+ result = find_map_entry_by_key (resource , "droppedAttributesCount" , 0 , FLB_TRUE );
769+ if (result >= 0 ) {
770+ obj = resource -> ptr [result ].val ;
771+ flb_log_event_encoder_append_body_values (encoder ,
772+ FLB_LOG_EVENT_CSTRING_VALUE ("dropped_attributes_count" ),
773+ FLB_LOG_EVENT_MSGPACK_OBJECT_VALUE (& obj ));
774+ }
773775 }
774776
775777 /* close resource map */
@@ -1299,28 +1301,28 @@ static int binary_payload_to_msgpack(struct flb_opentelemetry *ctx,
12991301 msgpack_pack_str_body (& mp_pck , "resource" , 8 );
13001302
13011303 flb_mp_map_header_init (& mh_tmp , & mp_pck );
1304+ if (resource ) {
1305+ /* look for OTel resource attributes */
1306+ if (resource -> n_attributes > 0 && resource -> attributes ) {
1307+ flb_mp_map_header_append (& mh_tmp );
1308+ msgpack_pack_str (& mp_pck , 10 );
1309+ msgpack_pack_str_body (& mp_pck , "attributes" , 10 );
13021310
1303- /* look for OTel resource attributes */
1304- if (resource -> n_attributes > 0 && resource -> attributes ) {
1305- flb_mp_map_header_append (& mh_tmp );
1306- msgpack_pack_str (& mp_pck , 10 );
1307- msgpack_pack_str_body (& mp_pck , "attributes" , 10 );
1308-
1309- ret = otel_pack_kvarray (& mp_pck ,
1310- resource -> attributes ,
1311- resource -> n_attributes );
1312- if (ret != 0 ) {
1313- return ret ;
1311+ ret = otel_pack_kvarray (& mp_pck ,
1312+ resource -> attributes ,
1313+ resource -> n_attributes );
1314+ if (ret != 0 ) {
1315+ return ret ;
1316+ }
13141317 }
1315- }
13161318
1317- if (resource -> dropped_attributes_count > 0 ) {
1318- flb_mp_map_header_append (& mh_tmp );
1319- msgpack_pack_str (& mp_pck , 24 );
1320- msgpack_pack_str_body (& mp_pck , "dropped_attributes_count" , 24 );
1321- msgpack_pack_uint64 (& mp_pck , resource -> dropped_attributes_count );
1319+ if (resource -> dropped_attributes_count > 0 ) {
1320+ flb_mp_map_header_append (& mh_tmp );
1321+ msgpack_pack_str (& mp_pck , 24 );
1322+ msgpack_pack_str_body (& mp_pck , "dropped_attributes_count" , 24 );
1323+ msgpack_pack_uint64 (& mp_pck , resource -> dropped_attributes_count );
1324+ }
13221325 }
1323-
13241326 flb_mp_map_header_end (& mh_tmp );
13251327
13261328 if (resource_log -> schema_url ) {
0 commit comments