From 8bad9a4a28bd71b7a5011652ca0a41bff3a9239d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tore=20Stendal=20L=C3=B8n=C3=B8y?= Date: Wed, 24 Jan 2024 08:24:11 +0100 Subject: [PATCH 1/4] docs: update otel example remove depcreated options and not-needed config entries --- docs/user-guide/third-party-addons/opentelemetry.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/user-guide/third-party-addons/opentelemetry.md b/docs/user-guide/third-party-addons/opentelemetry.md index a38c9c56f..f4ed576aa 100644 --- a/docs/user-guide/third-party-addons/opentelemetry.md +++ b/docs/user-guide/third-party-addons/opentelemetry.md @@ -152,9 +152,6 @@ To install the example and collectors run: ```yaml opentelemetry: enabled: true - image: registry.k8s.io/ingress-nginx/opentelemetry:v20230527@sha256:fd7ec835f31b7b37187238eb4fdad4438806e69f413a203796263131f4f02ed0 - containerSecurityContext: - allowPrivilegeEscalation: false ``` 2. Enable OpenTelemetry and set the otlp-collector-host: @@ -165,7 +162,6 @@ To install the example and collectors run: kind: ConfigMap data: enable-opentelemetry: "true" - opentelemetry-config: "/etc/ingress-controller/telemetry/opentelemetry.toml" opentelemetry-operation-name: "HTTP $request_method $service_name $uri" opentelemetry-trust-incoming-span: "true" otlp-collector-host: "otel-coll-collector.otel.svc" @@ -174,7 +170,7 @@ To install the example and collectors run: otel-schedule-delay-millis: "5000" otel-max-export-batch-size: "512" otel-service-name: "nginx-proxy" # Opentelemetry resource name - otel-sampler: "AlwaysOn" # Also: AlwaysOff, TraceIdRatioBased + otel-sampler: "AlwaysOn" # Also: AlwaysOff, TraceIdRatioBased. otel-sampler-ratio: "1.0" otel-sampler-parent-based: "false" metadata: From 87d750e573087f0b3188b16f73abafdc6d24d2b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tore=20Stendal=20L=C3=B8n=C3=B8y?= Date: Wed, 24 Jan 2024 11:00:00 +0100 Subject: [PATCH 2/4] docs: update otel related information --- .../nginx-configuration/configmap.md | 31 ++++++++++++++----- internal/ingress/controller/config/config.go | 4 +-- internal/ingress/controller/nginx.go | 2 +- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/docs/user-guide/nginx-configuration/configmap.md b/docs/user-guide/nginx-configuration/configmap.md index 7038ca90d..6bd6eb945 100644 --- a/docs/user-guide/nginx-configuration/configmap.md +++ b/docs/user-guide/nginx-configuration/configmap.md @@ -164,16 +164,16 @@ The following table shows a configuration option's name, type, and the default v |[enable-opentelemetry](#enable-opentelemetry)|bool|"false"|| |[opentelemetry-trust-incoming-span](#opentelemetry-trust-incoming-span)|bool|"true"|| |[opentelemetry-operation-name](#opentelemetry-operation-name)|string|""|| -|[opentelemetry-config](#/etc/ingress-controller/telemetry/opentelemetry.toml)|string|"/etc/ingress-controller/telemetry/opentelemetry.toml"|| +|[opentelemetry-config](#/etc/nginx/opentelemetry.toml)|string|"/etc/nginx/opentelemetry.toml"|| |[otlp-collector-host](#otlp-collector-host)|string|""|| |[otlp-collector-port](#otlp-collector-port)|int|4317|| -|[otel-max-queuesize](#otel-max-queuesize)|int||| -|[otel-schedule-delay-millis](#otel-schedule-delay-millis)|int||| -|[otel-max-export-batch-size](#otel-max-export-batch-size)|int||| -|[otel-service-name](#otel-service-name)|string|"nginx"|| -|[otel-sampler](#otel-sampler)|string|"AlwaysOff"|| +|[otel-max-export-batch-size](#otel-max-export-batch-size)|int|512|| +|[otel-max-queuesize](#otel-max-queuesize)|int|2048|| |[otel-sampler-parent-based](#otel-sampler-parent-based)|bool|"false"|| |[otel-sampler-ratio](#otel-sampler-ratio)|float|0.01|| +|[otel-sampler](#otel-sampler)|string|"AlwaysOn"|| +|[otel-schedule-delay-millis](#otel-schedule-delay-millis)|int|5000|| +|[otel-service-name](#otel-service-name)|string|"nginx"|| |[main-snippet](#main-snippet)|string|""|| |[http-snippet](#http-snippet)|string|""|| |[server-snippet](#server-snippet)|string|""|| @@ -1089,10 +1089,23 @@ Specifies the port to use when uploading traces. _**default:**_ 4317 Specifies the service name to use for any traces created. _**default:**_ nginx -## opentelemetry-trust-incoming-span: "true" +## opentelemetry-trust-incoming-span: + Enables or disables using spans from incoming requests as parent for created ones. _**default:**_ true -## otel-sampler-parent-based +## otel-max-export-batch-size + +The maximum batch size. Must be equal or smaller than [otel-max-export-batch-size](#otel-max-export-batch-size). _**default:**_ 512 + +## otel-schedule-delay-millis + +The interval, in milliseconds, between two consecutive exports. _**default:**_ 5000 + +## otel-max-queuesize + +The maximum queue size. _**default:**_ 2048 + +## otel-sampler-parent-based Uses sampler implementation which by default will take a sample if parent Activity is sampled. _**default:**_ false @@ -1104,6 +1117,8 @@ Specifies sample rate for any traces created. _**default:**_ 0.01 Specifies the sampler to be used when sampling traces. The available samplers are: AlwaysOff, AlwaysOn, TraceIdRatioBased, remote. _**default:**_ AlwaysOff +AlwaysOn is equivalent to setting [otel-sampler-ratio](#otel-sampler-ratio) to "1" and otel-sampler to "TraceIdRatioBased". + ## main-snippet Adds custom configuration to the main section of the nginx configuration. diff --git a/internal/ingress/controller/config/config.go b/internal/ingress/controller/config/config.go index bad82b8b0..35e50a069 100644 --- a/internal/ingress/controller/config/config.go +++ b/internal/ingress/controller/config/config.go @@ -888,10 +888,10 @@ func NewDefault() Configuration { BindAddressIpv4: defBindAddress, BindAddressIpv6: defBindAddress, OpentelemetryTrustIncomingSpan: true, - OpentelemetryConfig: "/etc/ingress-controller/telemetry/opentelemetry.toml", + OpentelemetryConfig: "/etc/nginx/opentelemetry.toml", OtlpCollectorPort: "4317", OtelServiceName: "nginx", - OtelSampler: "AlwaysOn", + OtelSampler: "AlwaysOff", OtelSamplerRatio: 0.01, OtelSamplerParentBased: true, OtelScheduleDelayMillis: 5000, diff --git a/internal/ingress/controller/nginx.go b/internal/ingress/controller/nginx.go index 578d5b4e8..0ac8e7ad6 100644 --- a/internal/ingress/controller/nginx.go +++ b/internal/ingress/controller/nginx.go @@ -1014,7 +1014,7 @@ max_export_batch_size = {{ .OtelMaxExportBatchSize }} name = "{{ .OtelServiceName }}" # Opentelemetry resource name [sampler] -name = "{{ .OtelSampler }}" # Also: AlwaysOff, TraceIdRatioBased +name = "{{ .OtelSampler }}" # Also: AlwaysOn, AlwaysOff, TraceIdRatioBased ratio = {{ .OtelSamplerRatio }} parent_based = {{ .OtelSamplerParentBased }} ` From 6bf7bac7abf3b753f6ef5067d52daa50caaeaced Mon Sep 17 00:00:00 2001 From: Tore Date: Thu, 25 Jan 2024 08:31:28 +0100 Subject: [PATCH 3/4] chore: remove default settings from example --- docs/user-guide/third-party-addons/opentelemetry.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/docs/user-guide/third-party-addons/opentelemetry.md b/docs/user-guide/third-party-addons/opentelemetry.md index f4ed576aa..6d4a30ea4 100644 --- a/docs/user-guide/third-party-addons/opentelemetry.md +++ b/docs/user-guide/third-party-addons/opentelemetry.md @@ -163,15 +163,10 @@ To install the example and collectors run: data: enable-opentelemetry: "true" opentelemetry-operation-name: "HTTP $request_method $service_name $uri" - opentelemetry-trust-incoming-span: "true" otlp-collector-host: "otel-coll-collector.otel.svc" - otlp-collector-port: "4317" - otel-max-queuesize: "2048" - otel-schedule-delay-millis: "5000" - otel-max-export-batch-size: "512" otel-service-name: "nginx-proxy" # Opentelemetry resource name - otel-sampler: "AlwaysOn" # Also: AlwaysOff, TraceIdRatioBased. - otel-sampler-ratio: "1.0" + otel-sampler: "TraceIdRatioBased" # Also: AlwaysOff, TraceIdRatioBased. + otel-sampler-ratio: "0.5" otel-sampler-parent-based: "false" metadata: name: ingress-nginx-controller From 003f04ca4563acb5d4c262ca391dca0ea05bf711 Mon Sep 17 00:00:00 2001 From: Tore Date: Thu, 25 Jan 2024 08:32:59 +0100 Subject: [PATCH 4/4] chore: revert back otel-sampler settings The documentation was inconsistent with the default value i config.go. To avoid breaking change, set OtelSampler back to AlwaysOn and update documentation to reflect this. The documentation was previously wrong. --- docs/user-guide/nginx-configuration/configmap.md | 4 ++-- internal/ingress/controller/config/config.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/user-guide/nginx-configuration/configmap.md b/docs/user-guide/nginx-configuration/configmap.md index 6bd6eb945..680c77b53 100644 --- a/docs/user-guide/nginx-configuration/configmap.md +++ b/docs/user-guide/nginx-configuration/configmap.md @@ -1115,9 +1115,9 @@ Specifies sample rate for any traces created. _**default:**_ 0.01 ## otel-sampler -Specifies the sampler to be used when sampling traces. The available samplers are: AlwaysOff, AlwaysOn, TraceIdRatioBased, remote. _**default:**_ AlwaysOff +Specifies the sampler to be used when sampling traces. The available samplers are: AlwaysOff, AlwaysOn, TraceIdRatioBased, remote. _**default:**_ AlwaysOn -AlwaysOn is equivalent to setting [otel-sampler-ratio](#otel-sampler-ratio) to "1" and otel-sampler to "TraceIdRatioBased". +"AlwaysOn" is equivalent to setting [otel-sampler-ratio](#otel-sampler-ratio) to "1" and otel-sampler to "TraceIdRatioBased". ## main-snippet diff --git a/internal/ingress/controller/config/config.go b/internal/ingress/controller/config/config.go index 35e50a069..8e684f428 100644 --- a/internal/ingress/controller/config/config.go +++ b/internal/ingress/controller/config/config.go @@ -891,7 +891,7 @@ func NewDefault() Configuration { OpentelemetryConfig: "/etc/nginx/opentelemetry.toml", OtlpCollectorPort: "4317", OtelServiceName: "nginx", - OtelSampler: "AlwaysOff", + OtelSampler: "AlwaysOn", OtelSamplerRatio: 0.01, OtelSamplerParentBased: true, OtelScheduleDelayMillis: 5000,