From d83d545e51bc1d8831473f0cf4f5ad4a3881c8db Mon Sep 17 00:00:00 2001 From: Bence Csati Date: Thu, 14 Nov 2024 17:03:31 +0100 Subject: [PATCH] chore: handle metrics breaking-change Signed-off-by: Bence Csati --- .../telemetry/otel_conf_gen/otel_conf_gen.go | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/internal/controller/telemetry/otel_conf_gen/otel_conf_gen.go b/internal/controller/telemetry/otel_conf_gen/otel_conf_gen.go index 2ae2e61..52a8d40 100644 --- a/internal/controller/telemetry/otel_conf_gen/otel_conf_gen.go +++ b/internal/controller/telemetry/otel_conf_gen/otel_conf_gen.go @@ -242,6 +242,34 @@ func (cfgInput *OtelColConfigInput) generateNamedPipelines() map[string]*otelv1b return namedPipelines } +func (cfgInput *OtelColConfigInput) generateTelemetry() map[string]any { + telemetry := map[string]interface{}{ + "metrics": map[string]interface{}{ + "level": "detailed", + "readers": []map[string]interface{}{ + { + "periodic": map[string]interface{}{ + "exporter": map[string]interface{}{ + "prometheus": map[string]interface{}{ + "host": "", + "port": 8888, + }, + }, + }, + }, + }, + }, + } + + if cfgInput.Debug { + telemetry["logs"] = map[string]string{ + "level": "debug", + } + } + + return telemetry +} + func (cfgInput *OtelColConfigInput) AssembleConfig(ctx context.Context) otelv1beta1.Config { exporters := cfgInput.generateExporters(ctx) @@ -255,17 +283,7 @@ func (cfgInput *OtelColConfigInput) AssembleConfig(ctx context.Context) otelv1be pipelines := cfgInput.generateNamedPipelines() - telemetry := make(map[string]any) - - telemetry["metrics"] = map[string]string{ - "level": "detailed", - } - - if cfgInput.Debug { - telemetry["logs"] = map[string]string{ - "level": "debug", - } - } + telemetry := cfgInput.generateTelemetry() if _, ok := processors["memory_limiter"]; ok { for name, pipeline := range pipelines {