From 011a0f9ddc820c71ed4601d4008af78df1d41e27 Mon Sep 17 00:00:00 2001 From: Donal Hurley Date: Thu, 26 Sep 2024 16:43:08 +0100 Subject: [PATCH] Fix collector extensions config (#870) --- internal/collector/otelcol.tmpl | 5 +++++ internal/config/config_test.go | 2 +- internal/config/types.go | 2 +- test/mock/collector/nginx-agent.conf | 2 +- test/types/config.go | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/collector/otelcol.tmpl b/internal/collector/otelcol.tmpl index 0cc28a215a..44b454ab8e 100644 --- a/internal/collector/otelcol.tmpl +++ b/internal/collector/otelcol.tmpl @@ -138,8 +138,13 @@ service: output_paths: ["{{ .Log.Path -}}"] error_output_paths: ["{{ .Log.Path -}}"] {{- end}} + + {{- if ne .Extensions nil }} extensions: + {{- if ne .Extensions.Health nil }} - health_check + {{- end}} + {{- end}} pipelines: metrics: receivers: diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 836ebb7ce0..b907f15bf6 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -366,7 +366,7 @@ func getAgentConfig() *Config { }, }, Extensions: Extensions{ - Health: Health{ + Health: &Health{ Server: &ServerConfig{ Host: "localhost", Port: 1337, diff --git a/internal/config/types.go b/internal/config/types.go index cfa80cf453..2765883048 100644 --- a/internal/config/types.go +++ b/internal/config/types.go @@ -95,7 +95,7 @@ type ( } Extensions struct { - Health Health `yaml:"-" mapstructure:"health"` + Health *Health `yaml:"-" mapstructure:"health"` } Health struct { diff --git a/test/mock/collector/nginx-agent.conf b/test/mock/collector/nginx-agent.conf index d67410115a..a06c12b934 100644 --- a/test/mock/collector/nginx-agent.conf +++ b/test/mock/collector/nginx-agent.conf @@ -51,7 +51,7 @@ collector: key: /tmp/key.pem generate_self_signed_cert: true processors: - batch: + batch: {} exporters: otlp_exporters: - server: diff --git a/test/types/config.go b/test/types/config.go index 15d82c278d..424f483ab3 100644 --- a/test/types/config.go +++ b/test/types/config.go @@ -84,7 +84,7 @@ func AgentConfig() *config.Config { }, }, Extensions: config.Extensions{ - Health: config.Health{ + Health: &config.Health{ Server: &config.ServerConfig{ Host: "localhost", Port: randomPort3,