Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
28 changes: 28 additions & 0 deletions .chloggen/mdatagen-fix-auto-enable-versioned-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Use this changelog template to create an entry for release notes.

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

# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp)
component: cmd/mdatagen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Auto-enable v1 metrics when legacy metric is enabled and v1 feature gate is on

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

# (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 the v1 feature gate is enabled and a legacy metric is enabled, the corresponding
v1 metric is now programmatically enabled so users don't need to add the v1 metric
to their config.

# 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: []

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

9 changes: 9 additions & 0 deletions cmd/mdatagen/internal/templates/metrics.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,15 @@ func NewMetricsBuilder(mbc MetricsBuilderConfig, settings {{ .Status.Class }}.Se
{{- range $name, $metric := .Metrics }}
{{- if $metric.Migration }}
if {{ printf "%s" $metric.Migration.ThroughGates.EnableNew | publicVar }}FeatureGate.IsEnabled() {
{{- /* If a legacy metric is enabled, programmatically enable the v1 metric.
The v1 metric may be disabled in metadata.yaml; when the v1 feature gate
is on we need to enable it automatically so users don't have to update
their config. */}}
if mb.metric{{ $name.Render }}.config.Enabled && !mb.metric{{ $metric.Migration.To.Render }}.config.enabledSetByUser {
mb.metric{{ $metric.Migration.To.Render }}.config.Enabled = true
mb.metric{{ $metric.Migration.To.Render }}.data = pmetric.NewMetric()
mb.metric{{ $metric.Migration.To.Render }}.init()
}
if mb.metric{{ $name.Render }}.config.Enabled && mb.metric{{ $metric.Migration.To.Render }}.config.Enabled {
var disable bool
if mb.metric{{ $name.Render }}.data.Type() != mb.metric{{ $metric.Migration.To.Render }}.data.Type() {
Expand Down
Loading