From e40e9e61b35309f174b15b1b6e2a2c08f4fe7d78 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Thu, 9 Apr 2026 18:50:08 +0200 Subject: [PATCH 1/2] [chore] Add linting rule to avoid manual creation of feature gates --- .golangci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index b5b376cf8c484..451731a711805 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -32,6 +32,7 @@ linters: - errcheck - errorlint - exhaustive + - forbidigo - gocritic - gosec - govet @@ -241,6 +242,14 @@ linters: files: - "!**/*_test.go" + forbidigo: + analyze-types: true + forbid: + - pattern: ^featuregate\.Registry\.(MustRegister|Register)$ + msg: >- + Define feature gates in metadata.yaml instead of registering them manually. + See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/46116. + exhaustive: # Presence of "default" case in switch statements satisfies exhaustiveness, # even if all enum members are not listed. From b231da4c59ad3c29f9ca483bc89fc458482c863a Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Thu, 9 Apr 2026 18:51:59 +0200 Subject: [PATCH 2/2] Add exclusion rules --- .golangci.yml | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 451731a711805..b9f884802c307 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -145,6 +145,95 @@ linters: path: internal/healthcheck/internal/http/ text: "var-naming: avoid package names that conflict with Go standard library package names" + # https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/46116 + - linters: + - forbidigo + path: connector/datadogconnector/ + - linters: + - forbidigo + path: connector/servicegraphconnector/ + - linters: + - forbidigo + path: connector/spanmetricsconnector/ + - linters: + - forbidigo + path: exporter/awsemfexporter/ + - linters: + - forbidigo + path: exporter/awsxrayexporter/ + - linters: + - forbidigo + path: exporter/clickhouseexporter/ + - linters: + - forbidigo + path: exporter/datadogexporter/ + - linters: + - forbidigo + path: exporter/googlecloudexporter/ + - linters: + - forbidigo + path: exporter/prometheusremotewriteexporter/ + - linters: + - forbidigo + path: exporter/signalfxexporter/ + - linters: + - forbidigo + path: extension/encoding/awslogsencodingextension/ + - linters: + - forbidigo + path: extension/healthcheckextension/ + - linters: + - forbidigo + path: extension/jaegerremotesampling/ + - linters: + - forbidigo + path: extension/opampextension/ + - linters: + - forbidigo + path: internal/filter/ + - linters: + - forbidigo + path: pkg/datadog/ + - linters: + - forbidigo + path: pkg/ottl/ + - linters: + - forbidigo + path: pkg/translator/prometheus/ + - linters: + - forbidigo + path: processor/filterprocessor/ + - linters: + - forbidigo + path: processor/metricsgenerationprocessor/ + - linters: + - forbidigo + path: processor/tailsamplingprocessor/ + - linters: + - forbidigo + path: processor/transformprocessor/ + - linters: + - forbidigo + path: receiver/awscontainerinsightreceiver/ + - linters: + - forbidigo + path: receiver/cloudfoundryreceiver/ + - linters: + - forbidigo + path: receiver/datadogreceiver/ + - linters: + - forbidigo + path: receiver/hostmetricsreceiver/ + - linters: + - forbidigo + path: receiver/jaegerreceiver/ + - linters: + - forbidigo + path: receiver/prometheusreceiver/ + - linters: + - forbidigo + path: receiver/vcenterreceiver/ + # Log a warning if an exclusion rule is unused. warn-unused: true