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..08623b6 100644 --- a/helm/config/nginx.conf +++ b/helm/config/nginx.conf @@ -13,6 +13,8 @@ events { http { + {{ include "nginx.otelRatioSampler" . | nindent 4 }} + {{ 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 */}}