diff --git a/cmd/ops_agent_uap_plugin/service_linux.go b/cmd/ops_agent_uap_plugin/service_linux.go index 233b9182a3..58b9607f74 100644 --- a/cmd/ops_agent_uap_plugin/service_linux.go +++ b/cmd/ops_agent_uap_plugin/service_linux.go @@ -137,7 +137,10 @@ func runSubagents(ctx context.Context, cancelAndSetError CancelContextAndSetPlug // Starting Otel runOtelCmd := exec.CommandContext(ctx, path.Join(pluginInstallDirectory, OtelBinary), - "--config", path.Join(pluginStateDirectory, OtelRuntimeDirectory, "otel.yaml"), + "--config", fmt.Sprintf("googlecloudopsagent:%s?platform=linux&state_dir=%s&out_dir=%s", + OpsAgentConfigLocationLinux, + path.Join(pluginStateDirectory, OtelStateDiectory), + path.Join(pluginStateDirectory, OtelRuntimeDirectory)), ) wg.Add(1) go runSubAgentCommand(ctx, cancelAndSetError, runOtelCmd, runCommand, &wg) diff --git a/cmd/ops_agent_windows/main_windows.go b/cmd/ops_agent_windows/main_windows.go index 44bd4403c5..ef6e1da9b6 100644 --- a/cmd/ops_agent_windows/main_windows.go +++ b/cmd/ops_agent_windows/main_windows.go @@ -136,7 +136,10 @@ func initServices() error { fmt.Sprintf("%s - Metrics Agent", serviceDisplayName), filepath.Join(base, "google-cloud-metrics-agent_windows_amd64.exe"), []string{ - "--config=" + filepath.Join(configOutDir, `otel\otel.yaml`), + fmt.Sprintf("--config=googlecloudopsagent:%s?platform=windows&state_dir=%s&out_dir=%s", + filepath.Join(base, "../config/config.yaml"), + filepath.Join(os.Getenv("PROGRAMDATA"), dataDirectory, "run"), + configOutDir), }, }, { diff --git a/confgenerator/files.go b/confgenerator/files.go index 23afc6b715..4b41091593 100644 --- a/confgenerator/files.go +++ b/confgenerator/files.go @@ -59,13 +59,8 @@ func (uc *UnifiedConfig) GenerateFilesFromConfig(ctx context.Context, service, l } } case "otel": - otelConfig, err := uc.GenerateOtelConfig(ctx, outDir, stateDir) - if err != nil { - return fmt.Errorf("can't parse configuration: %w", err) - } - if err = WriteConfigFile([]byte(otelConfig), filepath.Join(outDir, "otel.yaml")); err != nil { - return err - } + // No-op. otelopscol now uses the googlecloudopsagent provider to translate config on the fly. + return nil default: return fmt.Errorf("unknown service %q", service) } diff --git a/submodules/opentelemetry-operations-collector b/submodules/opentelemetry-operations-collector index ae68ccfcb4..ecabbc77c9 160000 --- a/submodules/opentelemetry-operations-collector +++ b/submodules/opentelemetry-operations-collector @@ -1 +1 @@ -Subproject commit ae68ccfcb4129c40f088e7cbe5a6cad88ab140ee +Subproject commit ecabbc77c92fc35af35141280423dd5f9e3b4300 diff --git a/systemd/google-cloud-ops-agent-opentelemetry-collector.service b/systemd/google-cloud-ops-agent-opentelemetry-collector.service index 023a59f83f..65f6c3479b 100644 --- a/systemd/google-cloud-ops-agent-opentelemetry-collector.service +++ b/systemd/google-cloud-ops-agent-opentelemetry-collector.service @@ -24,7 +24,7 @@ StateDirectory=google-cloud-ops-agent/opentelemetry-collector LogsDirectory=google-cloud-ops-agent Type=simple ExecStartPre=@PREFIX@/libexec/google_cloud_ops_agent_engine -service=otel -in @SYSCONFDIR@/google-cloud-ops-agent/config.yaml -logs ${LOGS_DIRECTORY} -state ${STATE_DIRECTORY} -ExecStart=@PREFIX@/subagents/opentelemetry-collector/otelopscol --config=${RUNTIME_DIRECTORY}/otel.yaml +ExecStart=@PREFIX@/subagents/opentelemetry-collector/otelopscol --config=googlecloudopsagent:@SYSCONFDIR@/google-cloud-ops-agent/config.yaml?platform=linux&state_dir=${STATE_DIRECTORY}&out_dir=${RUNTIME_DIRECTORY} Restart=always # For debugging: RuntimeDirectoryPreserve=yes