Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[confmap] Add featuregate to use stable expansion rules #10259

Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .chloggen/confmap-add-expand-featuregate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: confmap

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add `otelcol.unifyEnvVarExpansion` feature gate to allow enabling Collector/Configuration SIG environment variable expansion rules.
TylerHelmuth marked this conversation as resolved.
Show resolved Hide resolved

# One or more tracking issues or pull requests related to the change
issues: [10259]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
When enabled, this feature gate will:
- Disable expansion of BASH-style env vars (`$FOO`)
- `${FOO}` will be expanded as if it was `${env:FOO}
See https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/rfcs/env-vars.md for more details.

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
1 change: 1 addition & 0 deletions cmd/builder/internal/builder/templates/go.mod.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ go 1.21
require (
{{if .Distribution.SupportsConfmapFactories -}}
go.opentelemetry.io/collector/confmap/converter/expandconverter v{{.Distribution.OtelColVersion}}
go.opentelemetry.io/collector/featuregate v{{.Distribution.OtelColVersion}}
{{- range .Providers}}
{{if .GoMod}}{{.GoMod}}{{end}}
{{- end}}
Expand Down
21 changes: 18 additions & 3 deletions cmd/builder/internal/builder/templates/main.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ import (
{{- if .Distribution.SupportsConfmapFactories}}
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/confmap/converter/expandconverter"
"go.opentelemetry.io/collector/featuregate"
{{- range .Providers}}
{{.Name}} "{{.Import}}"
{{- end}}
{{- end}}
"go.opentelemetry.io/collector/otelcol"
)

{{ if .Distribution.SupportsConfmapFactories }}
var useUnifiedEnvVarExpansionRules = featuregate.GlobalRegistry().MustRegister("otelcol.unifyEnvVarExpansion",
TylerHelmuth marked this conversation as resolved.
Show resolved Hide resolved
featuregate.StageAlpha,
featuregate.WithRegisterFromVersion("v0.102.0"),
featuregate.WithRegisterDescription("`${FOO}` will now be expanded as if it was `${env:FOO}` and no longer expands $ENV syntax. See https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/rfcs/env-vars.md for more details."))
{{- end}}

func main() {
info := component.BuildInfo{
Command: "{{ .Distribution.Name }}",
Expand All @@ -38,14 +46,21 @@ func main() {
{{- if .ConfResolver.DefaultURIScheme }}
DefaultScheme: "{{ .ConfResolver.DefaultURIScheme }}",
{{- end }}
ConverterFactories: []confmap.ConverterFactory{
expandconverter.NewFactory(),
},
},
},
{{- end}}
}

{{ if .Distribution.SupportsConfmapFactories }}
if useUnifiedEnvVarExpansionRules.IsEnabled() && set.ConfigProviderSettings.ResolverSettings.DefaultScheme == "" {
set.ConfigProviderSettings.ResolverSettings.DefaultScheme = "env"
} else {
TylerHelmuth marked this conversation as resolved.
Show resolved Hide resolved
set.ConfigProviderSettings.ResolverSettings.ConverterFactories = []confmap.ConverterFactory{
expandconverter.NewFactory(),
}
}
{{- end}}

if err := run(set); err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/otelcorecol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ require (
go.opentelemetry.io/collector/extension/ballastextension v0.102.1
go.opentelemetry.io/collector/extension/memorylimiterextension v0.102.1
go.opentelemetry.io/collector/extension/zpagesextension v0.102.1
go.opentelemetry.io/collector/featuregate v1.9.0
go.opentelemetry.io/collector/otelcol v0.102.1
go.opentelemetry.io/collector/processor v0.102.1
go.opentelemetry.io/collector/processor/batchprocessor v0.102.1
Expand Down Expand Up @@ -92,7 +93,6 @@ require (
go.opentelemetry.io/collector/config/internal v0.102.1 // indirect
go.opentelemetry.io/collector/consumer v0.102.1 // indirect
go.opentelemetry.io/collector/extension/auth v0.102.1 // indirect
go.opentelemetry.io/collector/featuregate v1.9.0 // indirect
go.opentelemetry.io/collector/pdata v1.9.0 // indirect
go.opentelemetry.io/collector/semconv v0.102.1 // indirect
go.opentelemetry.io/collector/service v0.102.1 // indirect
Expand Down
17 changes: 14 additions & 3 deletions cmd/otelcorecol/main.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading