@@ -2670,6 +2670,69 @@ static int process_payload_logs_ng(struct flb_opentelemetry *ctx,
26702670 return ret ;
26712671}
26722672
2673+ static int ingest_profiles_context_as_log_entry (struct flb_opentelemetry * ctx ,
2674+ flb_sds_t tag ,
2675+ struct cprof * profiles_context )
2676+ {
2677+ cfl_sds_t text_encoded_profiles_context ;
2678+ struct flb_log_event_encoder * encoder ;
2679+ int ret ;
2680+
2681+ encoder = flb_log_event_encoder_create (FLB_LOG_EVENT_FORMAT_FLUENT_BIT_V2 );
2682+
2683+ if (encoder == NULL ) {
2684+ return -1 ;
2685+ }
2686+
2687+ ret = cprof_encode_text_create (& text_encoded_profiles_context , profiles_context );
2688+
2689+ if (ret != CPROF_ENCODE_TEXT_SUCCESS ) {
2690+ flb_log_event_encoder_destroy (encoder );
2691+
2692+ return -2 ;
2693+ }
2694+
2695+ flb_log_event_encoder_begin_record (encoder );
2696+
2697+ flb_log_event_encoder_set_current_timestamp (encoder );
2698+
2699+ ret = flb_log_event_encoder_append_body_values (
2700+ encoder ,
2701+ FLB_LOG_EVENT_CSTRING_VALUE ("Profile" ),
2702+ FLB_LOG_EVENT_STRING_VALUE (text_encoded_profiles_context ,
2703+ cfl_sds_len (text_encoded_profiles_context )));
2704+
2705+ cprof_encode_text_destroy (text_encoded_profiles_context );
2706+
2707+ if (ret != FLB_EVENT_ENCODER_SUCCESS ) {
2708+ flb_log_event_encoder_destroy (encoder );
2709+
2710+ return -3 ;
2711+ }
2712+
2713+ ret = flb_log_event_encoder_commit_record (encoder );
2714+
2715+ if (ret != FLB_EVENT_ENCODER_SUCCESS ) {
2716+ flb_log_event_encoder_destroy (encoder );
2717+
2718+ return -4 ;
2719+ }
2720+
2721+ ret = flb_input_log_append (ctx -> ins ,
2722+ tag ,
2723+ flb_sds_len (tag ),
2724+ encoder -> output_buffer ,
2725+ encoder -> output_length );
2726+
2727+ flb_log_event_encoder_destroy (encoder );
2728+
2729+ if (ret != FLB_EVENT_ENCODER_SUCCESS ) {
2730+ return -5 ;
2731+ }
2732+
2733+ return 0 ;
2734+ }
2735+
26732736static int process_payload_profiles_ng (struct flb_opentelemetry * ctx ,
26742737 flb_sds_t tag ,
26752738 struct flb_http_request * request ,
@@ -2719,10 +2782,17 @@ static int process_payload_profiles_ng(struct flb_opentelemetry *ctx,
27192782 return -1 ;
27202783 }
27212784
2722- ret = flb_input_profiles_append (ctx -> ins ,
2723- tag ,
2724- flb_sds_len (tag ),
2725- profiles_context );
2785+ if (ctx -> encode_profiles_as_text ) {
2786+ ret = ingest_profiles_context_as_log_entry (ctx ,
2787+ tag ,
2788+ profiles_context );
2789+ }
2790+ else {
2791+ ret = flb_input_profiles_append (ctx -> ins ,
2792+ tag ,
2793+ flb_sds_len (tag ),
2794+ profiles_context );
2795+ }
27262796
27272797 cprof_decode_opentelemetry_destroy (profiles_context );
27282798
0 commit comments