@@ -262,6 +262,8 @@ struct opentelemetry_context *flb_opentelemetry_context_create(struct flb_output
262262 const char * tmp = NULL ;
263263 uint64_t http_client_flags ;
264264 int http_protocol_version ;
265+ int http2_config_value ;
266+ int http2_effective_value ;
265267
266268 /* Allocate plugin context */
267269 ctx = flb_calloc (1 , sizeof (struct opentelemetry_context ));
@@ -627,22 +629,30 @@ struct opentelemetry_context *flb_opentelemetry_context_create(struct flb_output
627629
628630 ctx -> enable_http2_flag = FLB_TRUE ;
629631
632+ if (ctx -> enable_http2 ) {
633+ http2_config_value = flb_utils_bool (ctx -> enable_http2 );
634+ }
635+ else {
636+ http2_config_value = FLB_FALSE ;
637+ }
638+
639+ http2_effective_value = http2_config_value ;
640+
630641 /* if gRPC has been enabled, auto-enable HTTP/2 to make end-user life easier */
631- if (ctx -> enable_grpc_flag && ! flb_utils_bool ( ctx -> enable_http2 ) ) {
642+ if (ctx -> enable_grpc_flag && http2_config_value == FLB_FALSE ) {
632643 flb_plg_info (ctx -> ins , "gRPC enabled, HTTP/2 has been auto-enabled" );
633- flb_sds_destroy (ctx -> enable_http2 );
634- ctx -> enable_http2 = flb_sds_create ("on" );
644+ http2_effective_value = FLB_TRUE ;
635645 }
636646
637647 /*
638648 * 'force' aims to be used for plaintext communication when HTTP/2 is set. Note that
639649 * moving forward it wont be necessary since we are now setting some special defaults
640650 * in case of gRPC is enabled (which is the only case where HTTP/2 is mandatory).
641651 */
642- if (strcasecmp (ctx -> enable_http2 , "force" ) == 0 ) {
652+ if (ctx -> enable_http2 && strcasecmp (ctx -> enable_http2 , "force" ) == 0 ) {
643653 http_protocol_version = HTTP_PROTOCOL_VERSION_20 ;
644654 }
645- else if (flb_utils_bool ( ctx -> enable_http2 ) ) {
655+ else if (http2_effective_value == FLB_TRUE ) {
646656 if (!ins -> use_tls ) {
647657 http_protocol_version = HTTP_PROTOCOL_VERSION_20 ;
648658 }
0 commit comments