in otelcollector/shared/configmap/mp/tomlparser-debug-mode.go [21:85]
func ConfigureDebugModeSettings() error {
configMapSettings, err := parseConfigMapForDebugSettings()
if err != nil || configMapSettings == nil {
return fmt.Errorf("Error: %v", err)
}
enabled := populateSettingValuesFromConfigMap(configMapSettings)
configSchemaVersion := os.Getenv("AZMON_AGENT_CFG_SCHEMA_VERSION")
if configSchemaVersion != "" && strings.TrimSpace(configSchemaVersion) == "v1" {
if _, err := os.Stat(configMapDebugMountPath); os.IsNotExist(err) {
fmt.Printf("Unsupported/missing config schema version - '%s', using defaults, please use supported schema version\n", configSchemaVersion)
}
}
file, err := os.Create(debugModeEnvVarPath)
if err != nil {
return fmt.Errorf("Exception while opening file for writing prometheus-collector config environment variables: %v\n", err)
}
defer file.Close()
//if os.Getenv("OS_TYPE") != "" && strings.ToLower(os.Getenv("OS_TYPE")) == "linux" {
//file.WriteString(fmt.Sprintf("export DEBUG_MODE_ENABLED=%v\n", defaultEnabled))
//} else {
file.WriteString(fmt.Sprintf("DEBUG_MODE_ENABLED=%v\n", enabled))
fmt.Printf("Setting debug mode environment variable: %v\n", enabled)
//}
if enabled {
controllerType := os.Getenv("CONTROLLER_TYPE")
if controllerType != "" && controllerType == "ReplicaSet" {
fmt.Println("Setting prometheus in the exporter metrics for service pipeline since debug mode is enabled ...")
var config OtelConfig
content, err := os.ReadFile(replicaSetCollectorConfig)
if err != nil {
return fmt.Errorf("Exception while setting prometheus in the exporter metrics for service pipeline when debug mode is enabled - %v\n", err)
}
err = yaml.Unmarshal(content, &config)
if err != nil {
return fmt.Errorf("Exception while setting prometheus in the exporter metrics for service pipeline when debug mode is enabled - %v\n", err)
}
config.Service.Pipelines.Metrics.Exporters = []interface{}{"otlp", "prometheus"}
if os.Getenv("CCP_METRICS_ENABLED") != "true" {
config.Service.Pipelines.MetricsTelemetry.Receivers = []interface{}{"prometheus"}
config.Service.Pipelines.MetricsTelemetry.Exporters = []interface{}{"prometheus/telemetry"}
config.Service.Pipelines.MetricsTelemetry.Processors = []interface{}{"filter/telemetry"}
}
cfgYamlWithDebugModeSettings, err := yaml.Marshal(config)
if err != nil {
return fmt.Errorf("Exception while setting prometheus in the exporter metrics for service pipeline when debug mode is enabled - %v\n", err)
}
err = os.WriteFile(replicaSetCollectorConfig, []byte(cfgYamlWithDebugModeSettings), fs.FileMode(0644))
if err != nil {
return fmt.Errorf("Exception while setting prometheus in the exporter metrics for service pipeline when debug mode is enabled - %v\n", err)
}
fmt.Println("Done setting prometheus in the exporter metrics for service pipeline.")
}
}
return nil
}