Skip to content
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ec2b989
Fix mdatagen metadata loading to correctly handle deprecated metric f…
Syedowais312 Jan 10, 2026
37c5ba3
Update changelog for deprecated mdatagen metrics
Syedowais312 Jan 10, 2026
d6efd8b
Update changelog for deprecated mdatagen metrics-2
Syedowais312 Jan 10, 2026
1aa9d22
mdatagen: fix deprecated metric validation
Syedowais312 Jan 12, 2026
2d5acb4
mdatagen: enforce consistency between deprecated metrics and stability
Syedowais312 Jan 12, 2026
24d685a
Update cmd/mdatagen/metadata-schema.yaml
Syedowais312 Jan 12, 2026
b04ca26
Update cmd/mdatagen/metadata-schema.yaml
Syedowais312 Jan 12, 2026
71c5c87
Update cmd/mdatagen/metadata-schema.yaml
Syedowais312 Jan 12, 2026
6416001
mdatagen: fix deprecated metrics validation and schema
Syedowais312 Jan 12, 2026
688ecbd
add gogenerate changes
Syedowais312 Jan 13, 2026
d665c56
added license comment
Syedowais312 Jan 13, 2026
862aaaa
cmd/mdatagen: add test tp improve code coverage
Syedowais312 Jan 13, 2026
f85e8de
cmd/mdatagen: fix lint error - use assert.Empty instead of assert.Equ…
Syedowais312 Jan 13, 2026
96b6bdc
cmd/mdatagen: fix Stability.Unmarshal to support 'from' field and imp…
Syedowais312 Jan 13, 2026
cc6183d
Update .chloggen/fix_mdatagen-deprecated-metrics.yaml
Syedowais312 Jan 14, 2026
47e2d5e
Update changelog and removed deprecated stability validation test
Syedowais312 Jan 14, 2026
e408990
Clean up comments in Stability.Unmarshal method
Syedowais312 Jan 14, 2026
86670e9
Update metric.go
Syedowais312 Jan 14, 2026
75d4302
fix: lint
Syedowais312 Jan 14, 2026
17b7aba
fix: .chloggen
Syedowais312 Jan 14, 2026
e329b88
mdatagen: restore stability display to pre-PR behavior
Syedowais312 Jan 15, 2026
780ac78
WIP: update generated docs after stability handling changes
Syedowais312 Jan 15, 2026
cce9d72
mdatagen: validate deprecated metadata and align generated docs
Syedowais312 Jan 15, 2026
4f0bd8b
Update cmd/mdatagen/internal/metric.go
Syedowais312 Jan 15, 2026
27ea8e3
cmd/mdatagen: run gogenerate
Syedowais312 Jan 15, 2026
6ec7d80
Update cmd/mdatagen/internal/templates/documentation.md.tmpl
Syedowais312 Jan 16, 2026
a1cec0f
Update cmd/mdatagen/internal/templates/documentation.md.tmpl
Syedowais312 Jan 16, 2026
14fc754
Update cmd/mdatagen/internal/metadata.go
Syedowais312 Jan 16, 2026
7e477e7
Update cmd/mdatagen/internal/metric.go
Syedowais312 Jan 16, 2026
60b6888
Update gogenerate
Syedowais312 Jan 16, 2026
804526f
Merge branch 'main' into fix/mdatagen-deprecated-metrics
Syedowais312 Jan 16, 2026
c10cc73
Merge branch 'main' into fix/mdatagen-deprecated-metrics
Syedowais312 Jan 16, 2026
0c785bd
mdatagen: add stability tests
Syedowais312 Jan 22, 2026
b43b826
Remove logging note from metric.go
Syedowais312 Jan 22, 2026
f4cec89
mdatagen: add metric validation tests
Syedowais312 Jan 22, 2026
faee2b4
Fix deprecated.since version to match original from value
Syedowais312 Jan 23, 2026
659de09
Fix deprecated.since version to match original from value
Syedowais312 Jan 23, 2026
e8dfbf9
removed unrelated tests from metrics_test
Syedowais312 Jan 23, 2026
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
25 changes: 25 additions & 0 deletions .chloggen/fix_mdatagen-deprecated-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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. 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: "Introduce additional metadata (the version since the deprecation started, and the deprecation reason) for deprecated metrics."

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

# (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:

# 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: []
28 changes: 25 additions & 3 deletions cmd/mdatagen/internal/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func TestLoadMetadata(t *testing.T) {
Enabled: true,
Description: "Monotonic cumulative sum int metric enabled by default.",
ExtendedDocumentation: "The metric will be become optional soon.",
Stability: Stability{Level: component.StabilityLevelDevelopment},
Stability: Stability{Level: component.StabilityLevelDeprecated},
Warnings: Warnings{
IfEnabledNotSet: "This metric will be disabled by default soon.",
},
Expand All @@ -263,6 +263,10 @@ func TestLoadMetadata(t *testing.T) {
AggregationTemporality: AggregationTemporality{Aggregation: pmetric.AggregationTemporalityCumulative},
Mono: Mono{Monotonic: true},
},
Deprecated: &Deprecated{
Since: "1.0.0",
Note: "This metric will be removed",
},
},
"reaggregate.metric": {
Signal: Signal{
Expand Down Expand Up @@ -301,6 +305,10 @@ func TestLoadMetadata(t *testing.T) {
},
Attributes: []AttributeName{"string_attr", "boolean_attr", "boolean_attr2", "conditional_string_attr"},
},
Deprecated: &Deprecated{
Since: "1.0.0",
Note: "This metric will be removed",
},
Unit: strPtr("1"),
Gauge: &Gauge{
MetricValueType: MetricValueType{pmetric.NumberDataPointValueTypeDouble},
Expand All @@ -316,6 +324,10 @@ func TestLoadMetadata(t *testing.T) {
},
Attributes: []AttributeName{"string_attr", "boolean_attr"},
},
Deprecated: &Deprecated{
Since: "1.0.0",
Note: "This metric will be removed",
},
Unit: strPtr(""),
Gauge: &Gauge{
MetricValueType: MetricValueType{pmetric.NumberDataPointValueTypeDouble},
Expand All @@ -332,6 +344,10 @@ func TestLoadMetadata(t *testing.T) {
IfEnabled: "This metric is deprecated and will be removed soon.",
},
},
Deprecated: &Deprecated{
Since: "1.0.0",
Note: "This metric will be removed",
},
Unit: strPtr("s"),
Sum: &Sum{
MetricValueType: MetricValueType{pmetric.NumberDataPointValueTypeDouble},
Expand Down Expand Up @@ -393,10 +409,16 @@ func TestLoadMetadata(t *testing.T) {
Metrics: map[MetricName]Metric{
"batch_size_trigger_send": {
Signal: Signal{
Enabled: true,
Stability: Stability{Level: component.StabilityLevelDeprecated, From: "v0.110.0"},
Enabled: true,
Stability: Stability{
Level: component.StabilityLevelDeprecated,
},
Description: "Number of times the batch was sent due to a size trigger",
},
Deprecated: &Deprecated{
Since: "1.5.0",
Note: "This metric will be removed in favor of batch_send_trigger_size",
},
Unit: strPtr("{times}"),
Sum: &Sum{
MetricValueType: MetricValueType{pmetric.NumberDataPointValueTypeInt},
Expand Down
5 changes: 5 additions & 0 deletions cmd/mdatagen/internal/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ type Metadata struct {
FeatureGates []FeatureGate `mapstructure:"feature_gates"`
}

type Deprecated struct {
Since string `mapstructure:"since"`
Note string `mapstructure:"note"`
}

func (md Metadata) GetCodeCovComponentID() string {
if md.Status.CodeCovComponentID != "" {
return md.Status.CodeCovComponentID
Expand Down
35 changes: 31 additions & 4 deletions cmd/mdatagen/internal/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ type Metric struct {

// Override the default prefix for the metric name.
Prefix string `mapstructure:"prefix"`

// Deprecation metadata for deprecated metrics
Deprecated *Deprecated `mapstructure:"deprecated,omitempty"`
}

type Stability struct {
Expand All @@ -60,21 +63,45 @@ func (s Stability) String() string {
s.Level == component.StabilityLevelStable {
return ""
}
if s.From != "" {
return fmt.Sprintf(" [%s since %s]", s.Level.String(), s.From)
}
return fmt.Sprintf(" [%s]", s.Level.String())
}

// Unmarshal decodes the stability configuration.
// NOTE: confmap rejects unknown keys by default.
// The "from" field cannot be tested via full metadata loading
// unless WithIgnoreUnused() is used by the caller.
func (s *Stability) Unmarshal(parser *confmap.Conf) error {
if !parser.IsSet("level") {
return errors.New("missing required field: `stability.level`")
}
return parser.Unmarshal(s)

var level component.StabilityLevel
if err := parser.Unmarshal(&struct {
Level *component.StabilityLevel `mapstructure:"level"`
}{
Level: &level,
}); err != nil {
return err
}

s.Level = level

if parser.IsSet("from") {
if err := parser.Unmarshal(&struct {
From *string `mapstructure:"from"`
}{From: &s.From}); err != nil {
return err
}
}

return nil
}

func (m *Metric) validate(metricName MetricName, semConvVersion string) error {
var errs error
// TODO: Enforce deprecated metadata requirements once all components
// include deprecated fields consistently.
// See discussion in PR #14408.
if m.Sum == nil && m.Gauge == nil && m.Histogram == nil {
errs = errors.Join(errs, errors.New("missing metric type key, "+
"one of the following has to be specified: sum, gauge, histogram"))
Expand Down
Loading
Loading