@@ -530,6 +530,71 @@ func ParseConfigMap(ctx context.Context, cfgm *v1.ConfigMap, nginxPlus bool, has
530530 }
531531 }
532532
533+ if otelExporterEndpoint , exists := cfgm .Data ["otel-exporter-endpoint" ]; exists {
534+ otelExporterEndpoint = strings .TrimSpace (otelExporterEndpoint )
535+ if otelExporterEndpoint != "" {
536+ cfgParams .MainOtelExporterEndpoint = otelExporterEndpoint
537+ }
538+ }
539+
540+ if otelExporterTrustedCA , exists := cfgm .Data ["otel-exporter-trusted-ca" ]; exists {
541+ otelExporterTrustedCA = strings .TrimSpace (otelExporterTrustedCA )
542+ if otelExporterTrustedCA != "" {
543+ cfgParams .MainOtelExporterTrustedCA = otelExporterTrustedCA
544+ }
545+ }
546+
547+ if otelExporterHeaderName , exists := cfgm .Data ["otel-exporter-header-name" ]; exists {
548+ otelExporterHeaderName = strings .TrimSpace (otelExporterHeaderName )
549+ if otelExporterHeaderName != "" {
550+ cfgParams .MainOtelExporterHeaderName = otelExporterHeaderName
551+ }
552+ }
553+
554+ if otelExporterHeaderValue , exists := cfgm .Data ["otel-exporter-header-value" ]; exists {
555+ otelExporterHeaderValue = strings .TrimSpace (otelExporterHeaderValue )
556+ if otelExporterHeaderValue != "" {
557+ cfgParams .MainOtelExporterHeaderValue = otelExporterHeaderValue
558+ }
559+ }
560+
561+ if otelServiceName , exists := cfgm .Data ["otel-service-name" ]; exists {
562+ otelServiceName = strings .TrimSpace (otelServiceName )
563+ if otelServiceName != "" {
564+ cfgParams .MainOtelServiceName = otelServiceName
565+ }
566+ }
567+
568+ if otelGlobalTraceEnabled , exists , err := GetMapKeyAsBool (cfgm .Data , "otel-global-trace-enabled" , cfgm ); exists {
569+ if err != nil {
570+ nl .Error (l , err )
571+ eventLog .Event (cfgm , v1 .EventTypeWarning , nl .EventReasonInvalidValue , err .Error ())
572+ configOk = false
573+ }
574+ cfgParams .MainOtelGlobalTraceEnabled = otelGlobalTraceEnabled
575+ }
576+
577+ if cfgParams .MainOtelExporterEndpoint != "" {
578+ cfgParams .MainOtelLoadModule = true
579+ }
580+
581+ if otelEnabled , exists , err := GetMapKeyAsBool (cfgm .Data , "otel-enabled" , cfgm ); exists {
582+ if err != nil {
583+ nl .Error (l , err )
584+ eventLog .Event (cfgm , v1 .EventTypeWarning , nl .EventReasonInvalidValue , err .Error ())
585+ configOk = false
586+ } else {
587+ if cfgParams .MainOtelLoadModule {
588+ cfgParams .MainOtelEnabled = otelEnabled
589+ } else {
590+ errorText := fmt .Sprintf ("ConfigMap %s/%s: 'otel-enabled' is ignored because 'otel-exporter-endpoint' is not set, ignoring" , cfgm .GetNamespace (), cfgm .GetName ())
591+ nl .Error (l , errorText )
592+ eventLog .Event (cfgm , v1 .EventTypeWarning , nl .EventReasonInvalidValue , errorText )
593+ configOk = false
594+ }
595+ }
596+ }
597+
533598 if hasAppProtect {
534599 if appProtectFailureModeAction , exists := cfgm .Data ["app-protect-failure-mode-action" ]; exists {
535600 if appProtectFailureModeAction == "pass" || appProtectFailureModeAction == "drop" {
@@ -913,6 +978,14 @@ func GenerateNginxMainConfig(staticCfgParams *StaticConfigParams, config *Config
913978 NginxStatus : staticCfgParams .NginxStatus ,
914979 NginxStatusAllowCIDRs : staticCfgParams .NginxStatusAllowCIDRs ,
915980 NginxStatusPort : staticCfgParams .NginxStatusPort ,
981+ MainOtelEnabled : config .MainOtelEnabled ,
982+ MainOtelLoadModule : config .MainOtelLoadModule ,
983+ MainOtelGlobalTraceEnabled : config .MainOtelGlobalTraceEnabled ,
984+ MainOtelExporterEndpoint : config .MainOtelExporterEndpoint ,
985+ MainOtelExporterTrustedCA : config .MainOtelExporterTrustedCA ,
986+ MainOtelExporterHeaderName : config .MainOtelExporterHeaderName ,
987+ MainOtelExporterHeaderValue : config .MainOtelExporterHeaderValue ,
988+ MainOtelServiceName : config .MainOtelServiceName ,
916989 ProxyProtocol : config .ProxyProtocol ,
917990 ResolverAddresses : config .ResolverAddresses ,
918991 ResolverIPV6 : config .ResolverIPV6 ,
0 commit comments