From 9e9566ded6ad45b894bdd70401915adea3983ef5 Mon Sep 17 00:00:00 2001 From: almog8k Date: Sun, 12 Apr 2026 17:26:05 +0300 Subject: [PATCH 1/2] refactor(helm): move OpenTelemetry otelRatioSampler to helpers and update nginx.conf --- helm/config/default.conf | 8 -------- helm/config/nginx.conf | 2 ++ helm/templates/_helpers.tpl | 10 ++++++++++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/helm/config/default.conf b/helm/config/default.conf index 71295a1..f38abee 100644 --- a/helm/config/default.conf +++ b/helm/config/default.conf @@ -1,8 +1,3 @@ -split_clients "$otel_trace_id" $ratio_sampler { - {{ .Values.opentelemetry.ratio }}% on; - * off; -} - server { listen 8080; server_name localhost; @@ -12,9 +7,6 @@ server { include /etc/nginx/conf.d/{{ .Values.nginx.additionalConf.fileName }}; {{- end }} - # Include OpenTelemetry tracing configuration - {{ include "nginx.otelTrace" . | nindent 4 }} - # In case you use "add_header" in the location block, these "add_header" will be ignored! add_header 'Access-Control-Max-Age' '{{ .Values.nginx.maxAge | default "7200" }}'; add_header 'Access-Control-Allow-Origin' {{ .Values.nginx.allowedOrigins | default "*" | squote }}; diff --git a/helm/config/nginx.conf b/helm/config/nginx.conf index 478d43a..9640ddd 100644 --- a/helm/config/nginx.conf +++ b/helm/config/nginx.conf @@ -13,6 +13,8 @@ events { http { + {{ include "nginx.otelRatioSampler" . }} + {{ include "nginx.otelTrace" . | nindent 4 }} otel_service_name {{ .Values.opentelemetry.serviceName }}; otel_exporter { endpoint {{ .Values.opentelemetry.exporterHost }}:{{ .Values.opentelemetry.exporterPort }}; diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 55e756c..d8671aa 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -123,6 +123,16 @@ Returns the port for NGINX Prometheus Exporter {{ toJson $subPathsList }} {{- end -}} +{{/* +Generate OpenTelemetry ratio sampler split_clients block +*/}} +{{- define "nginx.otelRatioSampler" -}} +split_clients "$otel_trace_id" $ratio_sampler { + {{ .Values.opentelemetry.ratio }}% on; + * off; +} +{{- end -}} + {{/* Generate OpenTelemetry trace configuration */}} From d9acb1e0f57e9a6ead572bcac5805bf87002e4fb Mon Sep 17 00:00:00 2001 From: almog8k Date: Wed, 15 Apr 2026 09:41:40 +0300 Subject: [PATCH 2/2] refactor(helm): indent otelRatioSampler inclusion in nginx.conf --- helm/config/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/config/nginx.conf b/helm/config/nginx.conf index 9640ddd..08623b6 100644 --- a/helm/config/nginx.conf +++ b/helm/config/nginx.conf @@ -13,7 +13,7 @@ events { http { - {{ include "nginx.otelRatioSampler" . }} + {{ include "nginx.otelRatioSampler" . | nindent 4 }} {{ include "nginx.otelTrace" . | nindent 4 }} otel_service_name {{ .Values.opentelemetry.serviceName }}; otel_exporter {