diff --git a/internal/mode/static/nginx/config/generator_test.go b/internal/mode/static/nginx/config/generator_test.go index 07932d5fd6..ab3a387933 100644 --- a/internal/mode/static/nginx/config/generator_test.go +++ b/internal/mode/static/nginx/config/generator_test.go @@ -95,11 +95,11 @@ func TestGenerate(t *testing.T) { g.Expect(httpCfg).To(ContainSubstring("upstream")) g.Expect(httpCfg).To(ContainSubstring("split_clients")) - g.Expect(httpCfg).To(ContainSubstring("endpoint 1.2.3.4:123;")) - g.Expect(httpCfg).To(ContainSubstring("interval 5s;")) + g.Expect(httpCfg).To(ContainSubstring(`endpoint "1.2.3.4:123";`)) + g.Expect(httpCfg).To(ContainSubstring(`interval "5s";`)) g.Expect(httpCfg).To(ContainSubstring("batch_size 512;")) g.Expect(httpCfg).To(ContainSubstring("batch_count 4;")) - g.Expect(httpCfg).To(ContainSubstring("otel_service_name ngf:gw-ns:gw-name:my-name;")) + g.Expect(httpCfg).To(ContainSubstring(`otel_service_name "ngf:gw-ns:gw-name:my-name";`)) g.Expect(files[2].Type).To(Equal(file.TypeRegular)) g.Expect(files[2].Path).To(Equal("/etc/nginx/conf.d/config-version.conf")) diff --git a/internal/mode/static/nginx/config/telemetry_template.go b/internal/mode/static/nginx/config/telemetry_template.go index 7d41b5352d..6fcf297642 100644 --- a/internal/mode/static/nginx/config/telemetry_template.go +++ b/internal/mode/static/nginx/config/telemetry_template.go @@ -2,9 +2,9 @@ package config const otelTemplateText = ` otel_exporter { - endpoint {{ .Endpoint }}; + endpoint "{{ .Endpoint }}"; {{- if .Interval }} - interval {{ .Interval }}; + interval "{{ .Interval }}"; {{- end }} {{- if .BatchSize }} batch_size {{ .BatchSize }}; @@ -14,9 +14,9 @@ otel_exporter { {{- end }} } -otel_service_name {{ .ServiceName }}; +otel_service_name "{{ .ServiceName }}"; {{- range $attr := .SpanAttributes }} -otel_span_attr {{ $attr.Key }} {{ $attr.Value }}; +otel_span_attr "{{ $attr.Key }}" "{{ $attr.Value }}"; {{- end }} ` diff --git a/internal/mode/static/nginx/config/telemetry_test.go b/internal/mode/static/nginx/config/telemetry_test.go index ce7a05a8e8..bb361e285c 100644 --- a/internal/mode/static/nginx/config/telemetry_test.go +++ b/internal/mode/static/nginx/config/telemetry_test.go @@ -33,12 +33,12 @@ func TestExecuteTelemetry(t *testing.T) { g := NewWithT(t) expSubStrings := map[string]int{ - "endpoint 1.2.3.4:123;": 1, - "otel_service_name ngf:gw-ns:gw-name:my-name;": 1, - "interval 5s;": 1, - "batch_size 512;": 1, - "batch_count 4;": 1, - "otel_span_attr": 2, + `endpoint "1.2.3.4:123";`: 1, + `otel_service_name "ngf:gw-ns:gw-name:my-name";`: 1, + `interval "5s";`: 1, + "batch_size 512;": 1, + "batch_count 4;": 1, + "otel_span_attr": 2, } for expSubStr, expCount := range expSubStrings {