@@ -23,6 +23,8 @@ import (
23
23
"github.com/paypal/hera/cal"
24
24
"github.com/paypal/hera/config"
25
25
"github.com/paypal/hera/utility/logger"
26
+ otelconfig "github.com/paypal/hera/utility/logger/otel/config"
27
+
26
28
"os"
27
29
"path/filepath"
28
30
"strings"
@@ -236,7 +238,7 @@ func parseMapStrStr(encoded string) map[string]string {
236
238
}
237
239
238
240
// InitConfig initializes the configuration, both the static configuration (from hera.txt) and the dynamic configuration
239
- func InitConfig () error {
241
+ func InitConfig (poolName string ) error {
240
242
currentDir , abserr := filepath .Abs (filepath .Dir (os .Args [0 ]))
241
243
242
244
if abserr != nil {
@@ -488,9 +490,39 @@ func InitConfig() error {
488
490
gAppConfig .MaxDesiredHealthyWorkerPct = 90
489
491
}
490
492
493
+ //Initialize OTEL configs
494
+ initializeOTELConfigs (cdb , poolName )
495
+ if logger .GetLogger ().V (logger .Info ) {
496
+ otelconfig .OTelConfigData .Dump ()
497
+ }
491
498
return nil
492
499
}
493
500
501
+ // This function takes care of initialize OTEL configuration
502
+ func initializeOTELConfigs (cdb config.Config , poolName string ) {
503
+ otelconfig .OTelConfigData = & otelconfig.OTelConfig {}
504
+ //TODO initialize the values
505
+ otelconfig .OTelConfigData .Enabled = cdb .GetOrDefaultBool ("enable_otel" , false )
506
+ otelconfig .OTelConfigData .SkipCalStateLog = cdb .GetOrDefaultBool ("skip_cal_statelog" , false )
507
+ otelconfig .OTelConfigData .MetricNamePrefix = cdb .GetOrDefaultString ("otel_metric_prefix" , "pp.occ" )
508
+ otelconfig .OTelConfigData .Host = cdb .GetOrDefaultString ("otel_agent_host" , "localhost" )
509
+ otelconfig .OTelConfigData .MetricsPort = cdb .GetOrDefaultInt ("otel_agent_metrics_port" , 4318 )
510
+ otelconfig .OTelConfigData .TracePort = cdb .GetOrDefaultInt ("otel_agent_trace_port" , 4318 )
511
+ otelconfig .OTelConfigData .OtelMetricGRPC = cdb .GetOrDefaultBool ("otel_agent_use_grpc_metric" , false )
512
+ otelconfig .OTelConfigData .OtelTraceGRPC = cdb .GetOrDefaultBool ("otel_agent_use_grpc_trace" , false )
513
+ otelconfig .OTelConfigData .MetricsURLPath = cdb .GetOrDefaultString ("otel_agent_metrics_uri" , "" )
514
+ otelconfig .OTelConfigData .TraceURLPath = cdb .GetOrDefaultString ("otel_agent_trace_uri" , "" )
515
+ otelconfig .OTelConfigData .PoolName = poolName
516
+ otelconfig .OTelConfigData .UseTls = cdb .GetOrDefaultBool ("otel_use_tls" , false )
517
+ otelconfig .OTelConfigData .TLSCertPath = cdb .GetOrDefaultString ("otel_tls_cert_path" , "" )
518
+ otelconfig .OTelConfigData .ResolutionTimeInSec = cdb .GetOrDefaultInt ("otel_resolution_time_in_sec" , 1 )
519
+ otelconfig .OTelConfigData .ExporterTimeout = cdb .GetOrDefaultInt ("otel_exporter_time_in_sec" , 30 )
520
+ otelconfig .OTelConfigData .EnableRetry = cdb .GetOrDefaultBool ("otel_enable_exporter_retry" , false )
521
+ otelconfig .OTelConfigData .ResourceType = gAppConfig .StateLogPrefix
522
+ otelconfig .OTelConfigData .OTelErrorReportingInterval = cdb .GetOrDefaultInt ("otel_error_reporting_interval_in_sec" , 60 )
523
+ otelconfig .SetOTelIngestToken (cdb .GetOrDefaultString ("otel_ingest_token" , "" ))
524
+ }
525
+
494
526
func LogOccConfigs () {
495
527
whiteListConfigs := map [string ]map [string ]interface {}{
496
528
"BACKLOG" : {
@@ -503,6 +535,18 @@ func LogOccConfigs() {
503
535
"bouncer_startup_delay" : gAppConfig .BouncerStartupDelay ,
504
536
"bouncer_poll_interval_ms" : gAppConfig .BouncerPollInterval ,
505
537
},
538
+ "OTEL" : {
539
+ "enable_otel" : otelconfig .OTelConfigData .Enabled ,
540
+ "otel_use_tls" : otelconfig .OTelConfigData .UseTls ,
541
+ "skip_cal_statelog" : otelconfig .OTelConfigData .SkipCalStateLog ,
542
+ "otel_agent_host" : otelconfig .OTelConfigData .Host ,
543
+ "otel_agent_metrics_port" : otelconfig .OTelConfigData .MetricsPort ,
544
+ "otel_agent_trace_port" : otelconfig .OTelConfigData .TracePort ,
545
+ "otel_agent_metrics_uri" : otelconfig .OTelConfigData .MetricsURLPath ,
546
+ "otel_agent_trace_uri" : otelconfig .OTelConfigData .TraceURLPath ,
547
+ "otel_resolution_time_in_sec" : otelconfig .OTelConfigData .ResolutionTimeInSec ,
548
+ "otel_error_reporting_interval_in_sec" : otelconfig .OTelConfigData .OTelErrorReportingInterval ,
549
+ },
506
550
"PROFILE" : {
507
551
"enable_profile" : gAppConfig .EnableProfile ,
508
552
"profile_http_port" : gAppConfig .ProfileHTTPPort ,
@@ -618,6 +662,10 @@ func LogOccConfigs() {
618
662
if ! gAppConfig .BouncerEnabled {
619
663
continue
620
664
}
665
+ case "OTEL" :
666
+ if ! otelconfig .OTelConfigData .Enabled {
667
+ continue
668
+ }
621
669
case "PROFILE" :
622
670
if ! gAppConfig .EnableProfile {
623
671
continue
@@ -679,7 +727,6 @@ func LogOccConfigs() {
679
727
}
680
728
evt .Completed ()
681
729
}
682
-
683
730
}
684
731
685
732
// CheckOpsConfigChange checks if the ops config file needs to be reloaded and reloads it if necessary.
0 commit comments