Skip to content

Commit cce9d72

Browse files
committed
mdatagen: validate deprecated metadata and align generated docs
1 parent 780ac78 commit cce9d72

File tree

7 files changed

+119
-62
lines changed

7 files changed

+119
-62
lines changed

cmd/mdatagen/internal/metadata.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ type Deprecated struct {
6363
Note string `mapstructure:"note"`
6464
}
6565

66+
func (d *Deprecated) Validate() error {
67+
if strings.TrimSpace(d.Since) == "" {
68+
return errors.New("deprecated.since must be set")
69+
}
70+
71+
// NOTE: note is optional, but if present, it must not be empty
72+
if d.Note != "" && strings.TrimSpace(d.Note) == "" {
73+
return errors.New("deprecated.note must not be empty")
74+
}
75+
76+
return nil
77+
}
78+
6679
func (md Metadata) GetCodeCovComponentID() string {
6780
if md.Status.CodeCovComponentID != "" {
6881
return md.Status.CodeCovComponentID

cmd/mdatagen/internal/metric.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,13 @@ func (s *Stability) Unmarshal(parser *confmap.Conf) error {
9999

100100
func (m *Metric) validate(metricName MetricName, semConvVersion string) error {
101101
var errs error
102-
// TODO: Enforce deprecated metadata requirements once all components
103-
// include deprecated fields consistently.
104-
// See discussion in PR #14408.
102+
103+
if m.Deprecated != nil {
104+
if err := m.Deprecated.Validate(); err != nil {
105+
errs = errors.Join(errs, err)
106+
}
107+
}
108+
105109
if m.Sum == nil && m.Gauge == nil && m.Histogram == nil {
106110
errs = errors.Join(errs, errors.New("missing metric type key, "+
107111
"one of the following has to be specified: sum, gauge, histogram"))

cmd/mdatagen/internal/sampleconnector/documentation.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ The metric will be become optional soon.
3838
3939
The metric will be removed soon.
4040
41-
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability | Deprecation |
42-
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- | ----------- |
43-
| s | Sum | Double | Delta | false | Deprecated | since 1.0.0 (This metric will be removed) |
41+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
42+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
43+
| s | Sum | Double | Delta | false | Deprecated - Deprecated since 1.0.0 |
44+
45+
**Deprecation note**: This metric will be removed
4446
4547
### metric.input_type
4648
@@ -89,9 +91,11 @@ metrics:
8991
9092
[DEPRECATED] Gauge double metric disabled by default.
9193
92-
| Unit | Metric Type | Value Type | Stability | Deprecation |
93-
| ---- | ----------- | ---------- | --------- | ----------- |
94-
| 1 | Gauge | Double | Deprecated | since 1.0.0 (This metric will be removed) |
94+
| Unit | Metric Type | Value Type | Stability |
95+
| ---- | ----------- | ---------- | --------- |
96+
| 1 | Gauge | Double | Deprecated - Deprecated since 1.0.0 |
97+
98+
**Deprecation note**: This metric will be removed
9599
96100
#### Attributes
97101
@@ -105,9 +109,11 @@ metrics:
105109
106110
[DEPRECATED] Gauge double metric disabled by default.
107111
108-
| Unit | Metric Type | Value Type | Stability | Deprecation |
109-
| ---- | ----------- | ---------- | --------- | ----------- |
110-
| | Gauge | Double | Deprecated | since 1.0.0 (This metric will be removed) |
112+
| Unit | Metric Type | Value Type | Stability |
113+
| ---- | ----------- | ---------- | --------- |
114+
| | Gauge | Double | Deprecated - Deprecated since 1.0.0 |
115+
116+
**Deprecation note**: This metric will be removed
111117
112118
#### Attributes
113119

cmd/mdatagen/internal/samplereceiver/documentation.md

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ Monotonic cumulative sum int metric enabled by default.
1818
1919
The metric will be become optional soon.
2020
21-
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability | Deprecation |
22-
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- | ----------- |
23-
| s | Sum | Int | Cumulative | true | Deprecated | since 1.0.0 (This metric will be removed) |
21+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
22+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
23+
| s | Sum | Int | Cumulative | true | Deprecated - Deprecated since 1.0.0 |
24+
25+
**Deprecation note**: This metric will be removed
2426
2527
#### Attributes
2628
@@ -41,9 +43,11 @@ The metric will be become optional soon.
4143
4244
The metric will be removed soon.
4345
44-
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability | Deprecation |
45-
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- | ----------- |
46-
| s | Sum | Double | Delta | false | Deprecated | since 1.0.0 (This metric will be removed) |
46+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
47+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
48+
| s | Sum | Double | Delta | false | Deprecated - Deprecated since 1.0.0 |
49+
50+
**Deprecation note**: This metric will be removed
4751
4852
### metric.input_type
4953
@@ -102,9 +106,11 @@ metrics:
102106
103107
[DEPRECATED] Gauge double metric disabled by default.
104108
105-
| Unit | Metric Type | Value Type | Stability | Deprecation |
106-
| ---- | ----------- | ---------- | --------- | ----------- |
107-
| 1 | Gauge | Double | Deprecated | since 1.0.0 (This metric will be removed) |
109+
| Unit | Metric Type | Value Type | Stability |
110+
| ---- | ----------- | ---------- | --------- |
111+
| 1 | Gauge | Double | Deprecated - Deprecated since 1.0.0 |
112+
113+
**Deprecation note**: This metric will be removed
108114
109115
#### Attributes
110116
@@ -119,9 +125,11 @@ metrics:
119125
120126
[DEPRECATED] Gauge double metric disabled by default.
121127
122-
| Unit | Metric Type | Value Type | Stability | Deprecation |
123-
| ---- | ----------- | ---------- | --------- | ----------- |
124-
| | Gauge | Double | Deprecated | since 1.0.0 (This metric will be removed) |
128+
| Unit | Metric Type | Value Type | Stability |
129+
| ---- | ----------- | ---------- | --------- |
130+
| | Gauge | Double | Deprecated - Deprecated since 1.0.0 |
131+
132+
**Deprecation note**: This metric will be removed
125133
126134
#### Attributes
127135
@@ -222,9 +230,11 @@ Number of times the batch was sent due to a size trigger [Deprecated]
222230
> **Deprecated since 1.5.0**
223231
> This metric will be removed in favor of batch_send_trigger_size
224232
225-
| Unit | Metric Type | Value Type | Monotonic | Stability | Deprecation |
226-
| ---- | ----------- | ---------- | --------- | --------- | ----------- |
227-
| {times} | Sum | Int | true | Deprecated | since 1.5.0, note: This metric will be removed in favor of batch_send_trigger_size |
233+
| Unit | Metric Type | Value Type | Monotonic | Stability |
234+
| ---- | ----------- | ---------- | --------- | --------- |
235+
| {times} | Sum | Int | true | Deprecated - Deprecated since 1.5.0 |
236+
237+
**Deprecation note**: This metric will be removed in favor of batch_send_trigger_size
228238
229239
### otelcol_process_runtime_total_alloc_bytes
230240

cmd/mdatagen/internal/samplescraper/documentation.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ The metric will be become optional soon.
3838
3939
The metric will be removed soon.
4040
41-
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability | Deprecation |
42-
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- | ----------- |
43-
| s | Sum | Double | Delta | false | Deprecated | since 1.0.0 (This metric will be removed) |
41+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
42+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
43+
| s | Sum | Double | Delta | false | Deprecated - Deprecated since 1.0.0 |
44+
45+
**Deprecation note**: This metric will be removed
4446
4547
### metric.input_type
4648
@@ -99,9 +101,11 @@ metrics:
99101
100102
[DEPRECATED] Gauge double metric disabled by default.
101103
102-
| Unit | Metric Type | Value Type | Stability | Deprecation |
103-
| ---- | ----------- | ---------- | --------- | ----------- |
104-
| 1 | Gauge | Double | Deprecated | since 1.0.0 (This metric will be removed) |
104+
| Unit | Metric Type | Value Type | Stability |
105+
| ---- | ----------- | ---------- | --------- |
106+
| 1 | Gauge | Double | Deprecated - Deprecated since 1.0.0 |
107+
108+
**Deprecation note**: This metric will be removed
105109
106110
#### Attributes
107111
@@ -115,9 +119,11 @@ metrics:
115119
116120
[DEPRECATED] Gauge double metric disabled by default.
117121
118-
| Unit | Metric Type | Value Type | Stability | Deprecation |
119-
| ---- | ----------- | ---------- | --------- | ----------- |
120-
| | Gauge | Double | Deprecated | since 1.0.0 (This metric will be removed) |
122+
| Unit | Metric Type | Value Type | Stability |
123+
| ---- | ----------- | ---------- | --------- |
124+
| | Gauge | Double | Deprecated - Deprecated since 1.0.0 |
125+
126+
**Deprecation note**: This metric will be removed
121127
122128
#### Attributes
123129

cmd/mdatagen/internal/templates/documentation.md.tmpl

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111

1212
{{- end }}
1313

14-
| Unit | Metric Type | Value Type |{{ if $metric.Data.HasAggregated }} Aggregation Temporality |{{ end }}{{ if $metric.Data.HasMonotonic }} Monotonic |{{ end }}{{ if $metric.Stability.Level }} Stability |{{ end }}{{ if $metric.Deprecated }} Deprecation |{{ end }}{{ if $metric.SemanticConvention }} Semantic Convention |{{ end }}
15-
| ---- | ----------- | ---------- |{{ if $metric.Data.HasAggregated }} ----------------------- |{{ end }}{{ if $metric.Data.HasMonotonic }} --------- |{{ end }}{{ if $metric.Stability.Level }} --------- |{{ end }}{{ if $metric.Deprecated }} ----------- |{{ end }}{{ if $metric.SemanticConvention }} ------------------- |{{ end }}
14+
| Unit | Metric Type | Value Type |{{ if $metric.Data.HasAggregated }} Aggregation Temporality |{{ end }}{{ if $metric.Data.HasMonotonic }} Monotonic |{{ end }}{{ if $metric.Stability.Level }} Stability |{{ end }}{{ if $metric.SemanticConvention }} Semantic Convention |{{ end }}
15+
| ---- | ----------- | ---------- |{{ if $metric.Data.HasAggregated }} ----------------------- |{{ end }}{{ if $metric.Data.HasMonotonic }} --------- |{{ end }}{{ if $metric.Stability.Level }} --------- |{{ end }}{{ if $metric.SemanticConvention }} ------------------- |{{ end }}
1616
| {{ $metric.Unit }} | {{ $metric.Data.Type }} | {{ $metric.Data.MetricValueType }} |
1717
{{- if $metric.Data.HasAggregated }} {{ $metric.Data.AggregationTemporality }} |{{ end }}
1818
{{- if $metric.Data.HasMonotonic }} {{ $metric.Data.Monotonic }} |{{ end }}
19-
{{- if $metric.Stability.Level }} {{ $metric.Stability.Level }} |{{ end }}
20-
{{- if $metric.Deprecated }} since {{ $metric.Deprecated.Since }}{{ if $metric.Deprecated.Note }} ({{ $metric.Deprecated.Note }}){{ end }} |{{ end }}
19+
{{- if $metric.Stability.Level }} {{ $metric.Stability.Level }}{{ if $metric.Deprecated }} - Deprecated since {{ $metric.Deprecated.Since }}{{ end }} |{{ end }}
2120
{{- if $metric.SemanticConvention }} [{{ $metricName }}]({{ $metric.SemanticConvention.SemanticConventionRef }}) |{{ end }}
21+
{{- if $metric.Deprecated }}{{ if $metric.Deprecated.Note }}
22+
23+
**Deprecation note**: {{ $metric.Deprecated.Note }}
24+
{{- end }}{{ end }}
2225

2326
{{- if $metric.Attributes }}
2427

@@ -87,13 +90,16 @@
8790

8891
{{- end }}
8992

90-
| Unit | Metric Type | Value Type |{{ if $metric.Data.HasMonotonic }} Monotonic |{{ end }}{{ if $metric.Stability.Level }} Stability |{{ end }}{{ if $metric.Deprecated }} Deprecation |{{ end }}{{ if $metric.SemanticConvention }} Semantic Convention |{{ end }}
91-
| ---- | ----------- | ---------- |{{ if $metric.Data.HasMonotonic }} --------- |{{ end }}{{ if $metric.Stability.Level }} --------- |{{ end }}{{ if $metric.Deprecated }} ----------- |{{ end }}{{ if $metric.SemanticConvention }} ------------------- |{{ end }}
93+
| Unit | Metric Type | Value Type |{{ if $metric.Data.HasMonotonic }} Monotonic |{{ end }}{{ if $metric.Stability.Level }} Stability |{{ end }}{{ if $metric.SemanticConvention }} Semantic Convention |{{ end }}
94+
| ---- | ----------- | ---------- |{{ if $metric.Data.HasMonotonic }} --------- |{{ end }}{{ if $metric.Stability.Level }} --------- |{{ end }}{{ if $metric.SemanticConvention }} ------------------- |{{ end }}
9295
| {{ $metric.Unit }} | {{ $metric.Data.Type }} | {{ $metric.Data.MetricValueType }} |
9396
{{- if $metric.Data.HasMonotonic }} {{ $metric.Data.Monotonic }} |{{ end }}
94-
{{- if $metric.Stability.Level }} {{ $metric.Stability.Level }} |{{ end }}
95-
{{- if $metric.Deprecated }} since {{ $metric.Deprecated.Since }}{{ if $metric.Deprecated.Note }}, note: {{ $metric.Deprecated.Note }}{{ end }} |{{ end }}
97+
{{- if $metric.Stability.Level }} {{ $metric.Stability.Level }}{{ if $metric.Deprecated }} - Deprecated since {{ $metric.Deprecated.Since }}{{ end }} |{{ end }}
9698
{{- if $metric.SemanticConvention }} [{{ $metricName }}]({{ $metric.SemanticConvention.SemanticConventionRef }}) |{{ end }}
99+
{{- if $metric.Deprecated }}{{ if $metric.Deprecated.Note }}
100+
101+
**Deprecation note**: {{ $metric.Deprecated.Note }}
102+
{{- end }}{{ end }}
97103

98104
{{- if $metric.Attributes }}
99105

processor/memorylimiterprocessor/documentation.md

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ Number of log records successfully pushed into the next component in the pipelin
1313
> **Deprecated since 0.0.0**
1414
> This metric is deprecated
1515
16-
| Unit | Metric Type | Value Type | Monotonic | Stability | Deprecation |
17-
| ---- | ----------- | ---------- | --------- | --------- | ----------- |
18-
| {records} | Sum | Int | true | Deprecated | since 0.0.0, note: This metric is deprecated |
16+
| Unit | Metric Type | Value Type | Monotonic | Stability |
17+
| ---- | ----------- | ---------- | --------- | --------- |
18+
| {records} | Sum | Int | true | Deprecated - Deprecated since 0.0.0 |
19+
20+
**Deprecation note**: This metric is deprecated
1921

2022
### otelcol_processor_accepted_metric_points
2123

@@ -24,9 +26,11 @@ Number of metric points successfully pushed into the next component in the pipel
2426
> **Deprecated since 0.0.0**
2527
> This metric is deprecated
2628
27-
| Unit | Metric Type | Value Type | Monotonic | Stability | Deprecation |
28-
| ---- | ----------- | ---------- | --------- | --------- | ----------- |
29-
| {datapoints} | Sum | Int | true | Deprecated | since 0.0.0, note: This metric is deprecated |
29+
| Unit | Metric Type | Value Type | Monotonic | Stability |
30+
| ---- | ----------- | ---------- | --------- | --------- |
31+
| {datapoints} | Sum | Int | true | Deprecated - Deprecated since 0.0.0 |
32+
33+
**Deprecation note**: This metric is deprecated
3034

3135
### otelcol_processor_accepted_spans
3236

@@ -35,9 +39,11 @@ Number of spans successfully pushed into the next component in the pipeline. [De
3539
> **Deprecated since 0.0.0**
3640
> This metric is deprecated
3741
38-
| Unit | Metric Type | Value Type | Monotonic | Stability | Deprecation |
39-
| ---- | ----------- | ---------- | --------- | --------- | ----------- |
40-
| {spans} | Sum | Int | true | Deprecated | since 0.0.0, note: This metric is deprecated |
42+
| Unit | Metric Type | Value Type | Monotonic | Stability |
43+
| ---- | ----------- | ---------- | --------- | --------- |
44+
| {spans} | Sum | Int | true | Deprecated - Deprecated since 0.0.0 |
45+
46+
**Deprecation note**: This metric is deprecated
4147

4248
### otelcol_processor_refused_log_records
4349

@@ -46,9 +52,11 @@ Number of log records that were rejected by the next component in the pipeline.
4652
> **Deprecated since 0.0.0**
4753
> This metric is deprecated
4854
49-
| Unit | Metric Type | Value Type | Monotonic | Stability | Deprecation |
50-
| ---- | ----------- | ---------- | --------- | --------- | ----------- |
51-
| {records} | Sum | Int | true | Deprecated | since 0.0.0, note: This metric is deprecated |
55+
| Unit | Metric Type | Value Type | Monotonic | Stability |
56+
| ---- | ----------- | ---------- | --------- | --------- |
57+
| {records} | Sum | Int | true | Deprecated - Deprecated since 0.0.0 |
58+
59+
**Deprecation note**: This metric is deprecated
5260

5361
### otelcol_processor_refused_metric_points
5462

@@ -57,9 +65,11 @@ Number of metric points that were rejected by the next component in the pipeline
5765
> **Deprecated since 0.0.0**
5866
> This metric is deprecated
5967
60-
| Unit | Metric Type | Value Type | Monotonic | Stability | Deprecation |
61-
| ---- | ----------- | ---------- | --------- | --------- | ----------- |
62-
| {datapoints} | Sum | Int | true | Deprecated | since 0.0.0, note: This metric is deprecated |
68+
| Unit | Metric Type | Value Type | Monotonic | Stability |
69+
| ---- | ----------- | ---------- | --------- | --------- |
70+
| {datapoints} | Sum | Int | true | Deprecated - Deprecated since 0.0.0 |
71+
72+
**Deprecation note**: This metric is deprecated
6373

6474
### otelcol_processor_refused_spans
6575

@@ -68,6 +78,8 @@ Number of spans that were rejected by the next component in the pipeline. [Depre
6878
> **Deprecated since 0.0.0**
6979
> This metric is deprecated
7080
71-
| Unit | Metric Type | Value Type | Monotonic | Stability | Deprecation |
72-
| ---- | ----------- | ---------- | --------- | --------- | ----------- |
73-
| {spans} | Sum | Int | true | Deprecated | since 0.0.0, note: This metric is deprecated |
81+
| Unit | Metric Type | Value Type | Monotonic | Stability |
82+
| ---- | ----------- | ---------- | --------- | --------- |
83+
| {spans} | Sum | Int | true | Deprecated - Deprecated since 0.0.0 |
84+
85+
**Deprecation note**: This metric is deprecated

0 commit comments

Comments
 (0)