From 634b20d0d268ac99bc9c031b3e91dd7411cbd4dd Mon Sep 17 00:00:00 2001 From: Filip Haftek Date: Thu, 16 Jul 2026 11:13:20 +0200 Subject: [PATCH] featuer(otel-collector): ordered processors list) --- charts/sourcegraph/README.md | 1 + .../otel-collector.ConfigMap.yaml | 6 ++ .../tests/otelCollectorProcessors_test.yaml | 72 +++++++++++++++++++ charts/sourcegraph/values.yaml | 4 ++ 4 files changed, 83 insertions(+) create mode 100644 charts/sourcegraph/tests/otelCollectorProcessors_test.yaml diff --git a/charts/sourcegraph/README.md b/charts/sourcegraph/README.md index e0dcc76f..7e6e23ee 100644 --- a/charts/sourcegraph/README.md +++ b/charts/sourcegraph/README.md @@ -227,6 +227,7 @@ In addition to the documented values, all services also support the following va | openTelemetry.enabled | bool | `true` | | | openTelemetry.gateway.config.traces.exporters | object | `{}` | Define where traces should be exported to. Read how to configure different backends in the [OpenTelemetry documentation](https://opentelemetry.io/docs/collector/configuration/#exporters) | | openTelemetry.gateway.config.traces.exportersTlsSecretName | string | `""` | Define the name of a preexisting secret containing TLS certificates for exporters, which will be mounted under "/tls". Read more about TLS configuration of exporters in the [OpenTelemetry Collector documentation](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configtls/README.md) | +| openTelemetry.gateway.config.traces.processorOrderedList | list | `[]` | Define the order in which trace processors run in the pipeline. When set, this takes precedence over the iteration order of `processors` (which cannot be relied on to preserve insertion order). Must contain exactly the same processor names as the keys of `processors`. | | openTelemetry.gateway.config.traces.processors | object | `{}` | Define trace processors. Read how to configure sampling in the [OpenTelemetry documentation](https://docs.sourcegraph.com/admin/observability/opentelemetry#sampling-traces) | | openTelemetry.gateway.containerSecurityContext.allowPrivilegeEscalation | bool | `false` | | | openTelemetry.gateway.containerSecurityContext.runAsGroup | int | `101` | | diff --git a/charts/sourcegraph/templates/otel-collector/otel-collector.ConfigMap.yaml b/charts/sourcegraph/templates/otel-collector/otel-collector.ConfigMap.yaml index 4a42db65..a1140960 100644 --- a/charts/sourcegraph/templates/otel-collector/otel-collector.ConfigMap.yaml +++ b/charts/sourcegraph/templates/otel-collector/otel-collector.ConfigMap.yaml @@ -44,9 +44,15 @@ data: - otlp {{- if .Values.openTelemetry.gateway.config.traces.processors }} processors: + {{- if .Values.openTelemetry.gateway.config.traces.processorOrderedList }} + {{- range .Values.openTelemetry.gateway.config.traces.processorOrderedList }} + - {{ . }} + {{- end }} + {{- else }} {{- range $key, $val := .Values.openTelemetry.gateway.config.traces.processors }} - {{ $key }} {{- end }} + {{- end }} {{- end }} exporters: {{- range $key, $val := .Values.openTelemetry.gateway.config.traces.exporters }} diff --git a/charts/sourcegraph/tests/otelCollectorProcessors_test.yaml b/charts/sourcegraph/tests/otelCollectorProcessors_test.yaml new file mode 100644 index 00000000..500bd3bf --- /dev/null +++ b/charts/sourcegraph/tests/otelCollectorProcessors_test.yaml @@ -0,0 +1,72 @@ +--- +suite: otelCollectorProcessors +templates: + - otel-collector/otel-collector.ConfigMap.yaml +set: + openTelemetry: + gateway: + config: + traces: + exporters: + otlp: + endpoint: "otlp.service.com:443" +tests: + - it: should not render a processors section when none are configured + asserts: + - notMatchRegex: + path: data["config.yaml"] + pattern: "processors:" + - it: should order pipeline processors by map key when processorOrderedList is not set + set: + openTelemetry: + gateway: + config: + traces: + processors: + memory_limiter: + check_interval: 1s + batch: + timeout: 1s + asserts: + - matchRegex: + path: data["config.yaml"] + pattern: "processors:\\s*\\n\\s*- batch\\s*\\n\\s*- memory_limiter" + - it: should order pipeline processors using processorOrderedList when set + set: + openTelemetry: + gateway: + config: + traces: + processors: + memory_limiter: + check_interval: 1s + batch: + timeout: 1s + processorOrderedList: + - memory_limiter + - batch + asserts: + - matchRegex: + path: data["config.yaml"] + pattern: "processors:\\s*\\n\\s*- memory_limiter\\s*\\n\\s*- batch" + - it: should still define processor configs regardless of ordering source + set: + openTelemetry: + gateway: + config: + traces: + processors: + memory_limiter: + check_interval: 1s + batch: + timeout: 1s + processorOrderedList: + - memory_limiter + - batch + asserts: + - matchRegex: + path: data["config.yaml"] + pattern: "check_interval: 1s" + - matchRegex: + path: data["config.yaml"] + pattern: "timeout: 1s" diff --git a/charts/sourcegraph/values.yaml b/charts/sourcegraph/values.yaml index 55cebae9..895af675 100644 --- a/charts/sourcegraph/values.yaml +++ b/charts/sourcegraph/values.yaml @@ -665,6 +665,10 @@ openTelemetry: # -- Define trace processors. # Read how to configure sampling in the [OpenTelemetry documentation](https://docs.sourcegraph.com/admin/observability/opentelemetry#sampling-traces) processors: {} + # -- Define the order in which trace processors run in the pipeline. When set, this takes + # precedence over the iteration order of `processors` (which cannot be relied on to preserve + # insertion order). Must contain exactly the same processor names as the keys of `processors`. + processorOrderedList: [] # -- Define where traces should be exported to. # Read how to configure different backends in the [OpenTelemetry documentation](https://opentelemetry.io/docs/collector/configuration/#exporters) exporters: {}