@@ -764,12 +764,14 @@ static int process_json_payload_resource_logs_entry(struct flb_opentelemetry *ct
764
764
}
765
765
766
766
/* 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
+ }
773
775
}
774
776
775
777
/* close resource map */
@@ -1299,28 +1301,28 @@ static int binary_payload_to_msgpack(struct flb_opentelemetry *ctx,
1299
1301
msgpack_pack_str_body (& mp_pck , "resource" , 8 );
1300
1302
1301
1303
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 );
1302
1310
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
+ }
1314
1317
}
1315
- }
1316
1318
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
+ }
1322
1325
}
1323
-
1324
1326
flb_mp_map_header_end (& mh_tmp );
1325
1327
1326
1328
if (resource_log -> schema_url ) {
0 commit comments