Skip to content

Commit 506a9c3

Browse files
committed
[mdatagen] Set metrics' default stability to development
Signed-off-by: ChrsMark <[email protected]>
1 parent ba0b327 commit 506a9c3

File tree

11 files changed

+110
-65
lines changed

11 files changed

+110
-65
lines changed

cmd/mdatagen/internal/loader.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"path/filepath"
1212
"strings"
1313

14+
"go.opentelemetry.io/collector/component"
15+
1416
"go.opentelemetry.io/collector/confmap/confmaptest"
1517
"go.opentelemetry.io/collector/confmap/provider/fileprovider"
1618
)
@@ -63,10 +65,24 @@ func LoadMetadata(filePath string) (Metadata, error) {
6365

6466
setAttributesFullName(md.Attributes)
6567
setAttributesFullName(md.ResourceAttributes)
68+
setDefaultMetricStabilityLevel(md.Metrics)
69+
70+
//for _, metric := range md.Metrics {
71+
// panic(metric.Stability.Level.String())
72+
//}
6673

6774
return md, nil
6875
}
6976

77+
func setDefaultMetricStabilityLevel(metrics map[MetricName]Metric) {
78+
for mName, metric := range metrics {
79+
if metric.Stability.Level == component.StabilityLevelUndefined {
80+
metric.Stability.Level = component.StabilityLevelDevelopment
81+
metrics[mName] = metric
82+
}
83+
}
84+
}
85+
7086
var componentTypes = []string{
7187
"connector",
7288
"exporter",

cmd/mdatagen/internal/loader_test.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ func TestLoadMetadata(t *testing.T) {
221221
Enabled: true,
222222
Description: "Monotonic cumulative sum int metric enabled by default.",
223223
ExtendedDocumentation: "The metric will be become optional soon.",
224+
Stability: Stability{
225+
Level: component.StabilityLevelDevelopment,
226+
},
224227
Warnings: Warnings{
225228
IfEnabledNotSet: "This metric will be disabled by default soon.",
226229
},
@@ -237,6 +240,7 @@ func TestLoadMetadata(t *testing.T) {
237240
Signal: Signal{
238241
Enabled: false,
239242
Description: "[DEPRECATED] Gauge double metric disabled by default.",
243+
Stability: Stability{Level: component.StabilityLevelDeprecated},
240244
Warnings: Warnings{
241245
IfConfigured: "This metric is deprecated and will be removed soon.",
242246
},
@@ -251,6 +255,7 @@ func TestLoadMetadata(t *testing.T) {
251255
Signal: Signal{
252256
Enabled: false,
253257
Description: "[DEPRECATED] Gauge double metric disabled by default.",
258+
Stability: Stability{Level: component.StabilityLevelDeprecated},
254259
Warnings: Warnings{
255260
IfConfigured: "This metric is deprecated and will be removed soon.",
256261
},
@@ -265,6 +270,7 @@ func TestLoadMetadata(t *testing.T) {
265270
"default.metric.to_be_removed": {
266271
Signal: Signal{
267272
Enabled: true,
273+
Stability: Stability{Level: component.StabilityLevelDeprecated},
268274
Description: "[DEPRECATED] Non-monotonic delta sum double metric enabled by default.",
269275
ExtendedDocumentation: "The metric will be removed soon.",
270276
Warnings: Warnings{
@@ -280,7 +286,10 @@ func TestLoadMetadata(t *testing.T) {
280286
},
281287
"metric.input_type": {
282288
Signal: Signal{
283-
Enabled: true,
289+
Enabled: true,
290+
Stability: Stability{
291+
Level: component.StabilityLevelBeta,
292+
},
284293
Description: "Monotonic cumulative sum int metric with string input_type enabled by default.",
285294
Attributes: []AttributeName{"string_attr", "overridden_int_attr", "enum_attr", "slice_attr", "map_attr"},
286295
},
@@ -332,7 +341,7 @@ func TestLoadMetadata(t *testing.T) {
332341
"batch_size_trigger_send": {
333342
Signal: Signal{
334343
Enabled: true,
335-
Stability: Stability{Level: "deprecated", From: "v0.110.0"},
344+
Stability: Stability{Level: component.StabilityLevelDeprecated, From: "v0.110.0"},
336345
Description: "Number of times the batch was sent due to a size trigger",
337346
},
338347
Unit: strPtr("{times}"),
@@ -344,7 +353,7 @@ func TestLoadMetadata(t *testing.T) {
344353
"request_duration": {
345354
Signal: Signal{
346355
Enabled: true,
347-
Stability: Stability{Level: "alpha"},
356+
Stability: Stability{Level: component.StabilityLevelAlpha},
348357
Description: "Duration of request",
349358
},
350359
Unit: strPtr("s"),
@@ -356,7 +365,7 @@ func TestLoadMetadata(t *testing.T) {
356365
"process_runtime_total_alloc_bytes": {
357366
Signal: Signal{
358367
Enabled: true,
359-
Stability: Stability{Level: "stable"},
368+
Stability: Stability{Level: component.StabilityLevelStable},
360369
Description: "Cumulative bytes allocated for heap objects (see 'go doc runtime.MemStats.TotalAlloc')",
361370
},
362371
Unit: strPtr("By"),
@@ -371,7 +380,7 @@ func TestLoadMetadata(t *testing.T) {
371380
"queue_length": {
372381
Signal: Signal{
373382
Enabled: true,
374-
Stability: Stability{Level: "alpha"},
383+
Stability: Stability{Level: component.StabilityLevelAlpha},
375384
Description: "This metric is optional and therefore not initialized in NewTelemetryBuilder.",
376385
ExtendedDocumentation: "For example this metric only exists if feature A is enabled.",
377386
},

cmd/mdatagen/internal/metric.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package internal // import "go.opentelemetry.io/collector/cmd/mdatagen/internal"
66
import (
77
"errors"
88
"fmt"
9-
"strings"
109

1110
"golang.org/x/text/cases"
1211
"golang.org/x/text/language"
@@ -48,18 +47,19 @@ type Metric struct {
4847
}
4948

5049
type Stability struct {
51-
Level string `mapstructure:"level"`
52-
From string `mapstructure:"from"`
50+
Level component.StabilityLevel `mapstructure:"level"`
51+
From string `mapstructure:"from"`
5352
}
5453

5554
func (s Stability) String() string {
56-
if s.Level == "" || strings.EqualFold(s.Level, component.StabilityLevelStable.String()) {
55+
if s.Level == component.StabilityLevelUndefined ||
56+
s.Level == component.StabilityLevelStable {
5757
return ""
5858
}
5959
if s.From != "" {
60-
return fmt.Sprintf(" [%s since %s]", s.Level, s.From)
60+
return fmt.Sprintf(" [%s since %s]", s.Level.String(), s.From)
6161
}
62-
return fmt.Sprintf(" [%s]", s.Level)
62+
return fmt.Sprintf(" [%s]", s.Level.String())
6363
}
6464

6565
func (m *Metric) validate() error {

cmd/mdatagen/internal/sampleconnector/documentation.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ 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 |
22-
| ---- | ----------- | ---------- | ----------------------- | --------- |
23-
| s | Sum | Int | Cumulative | true |
21+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
22+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
23+
| s | Sum | Int | Cumulative | true | Development |
2424
2525
#### Attributes
2626
@@ -38,17 +38,17 @@ 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 |
42-
| ---- | ----------- | ---------- | ----------------------- | --------- |
43-
| s | Sum | Double | Delta | false |
41+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
42+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
43+
| s | Sum | Double | Delta | false | Deprecated |
4444
4545
### metric.input_type
4646
4747
Monotonic cumulative sum int metric with string input_type enabled by default.
4848
49-
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
50-
| ---- | ----------- | ---------- | ----------------------- | --------- |
51-
| s | Sum | Int | Cumulative | true |
49+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
50+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
51+
| s | Sum | Int | Cumulative | true | Beta |
5252
5353
#### Attributes
5454
@@ -74,9 +74,9 @@ metrics:
7474
7575
[DEPRECATED] Gauge double metric disabled by default.
7676
77-
| Unit | Metric Type | Value Type |
78-
| ---- | ----------- | ---------- |
79-
| 1 | Gauge | Double |
77+
| Unit | Metric Type | Value Type | Stability |
78+
| ---- | ----------- | ---------- | --------- |
79+
| 1 | Gauge | Double | Deprecated |
8080
8181
#### Attributes
8282
@@ -90,9 +90,9 @@ metrics:
9090
9191
[DEPRECATED] Gauge double metric disabled by default.
9292
93-
| Unit | Metric Type | Value Type |
94-
| ---- | ----------- | ---------- |
95-
| | Gauge | Double |
93+
| Unit | Metric Type | Value Type | Stability |
94+
| ---- | ----------- | ---------- | --------- |
95+
| | Gauge | Double | Deprecated |
9696
9797
#### Attributes
9898

cmd/mdatagen/internal/sampleconnector/metadata.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ metrics:
116116
enabled: false
117117
description: "[DEPRECATED] Gauge double metric disabled by default."
118118
unit: "1"
119+
stability:
120+
level: deprecated
119121
gauge:
120122
value_type: double
121123
attributes: [string_attr, boolean_attr, boolean_attr2]
@@ -126,6 +128,8 @@ metrics:
126128
enabled: false
127129
description: "[DEPRECATED] Gauge double metric disabled by default."
128130
unit: ""
131+
stability:
132+
level: deprecated
129133
gauge:
130134
value_type: double
131135
attributes: [string_attr, boolean_attr]
@@ -136,6 +140,8 @@ metrics:
136140
enabled: true
137141
description: "[DEPRECATED] Non-monotonic delta sum double metric enabled by default."
138142
extended_documentation: The metric will be removed soon.
143+
stability:
144+
level: deprecated
139145
unit: s
140146
sum:
141147
value_type: double
@@ -146,6 +152,8 @@ metrics:
146152

147153
metric.input_type:
148154
enabled: true
155+
stability:
156+
level: beta
149157
description: Monotonic cumulative sum int metric with string input_type enabled by default.
150158
unit: s
151159
sum:

cmd/mdatagen/internal/samplereceiver/documentation.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ 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 |
22-
| ---- | ----------- | ---------- | ----------------------- | --------- |
23-
| s | Sum | Int | Cumulative | true |
21+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
22+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
23+
| s | Sum | Int | Cumulative | true | Development |
2424
2525
#### Attributes
2626
@@ -40,17 +40,17 @@ The metric will be become optional soon.
4040
4141
The metric will be removed soon.
4242
43-
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
44-
| ---- | ----------- | ---------- | ----------------------- | --------- |
45-
| s | Sum | Double | Delta | false |
43+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
44+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
45+
| s | Sum | Double | Delta | false | Deprecated |
4646
4747
### metric.input_type
4848
4949
Monotonic cumulative sum int metric with string input_type enabled by default.
5050
51-
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
52-
| ---- | ----------- | ---------- | ----------------------- | --------- |
53-
| s | Sum | Int | Cumulative | true |
51+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
52+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
53+
| s | Sum | Int | Cumulative | true | Beta |
5454
5555
#### Attributes
5656
@@ -76,9 +76,9 @@ metrics:
7676
7777
[DEPRECATED] Gauge double metric disabled by default.
7878
79-
| Unit | Metric Type | Value Type |
80-
| ---- | ----------- | ---------- |
81-
| 1 | Gauge | Double |
79+
| Unit | Metric Type | Value Type | Stability |
80+
| ---- | ----------- | ---------- | --------- |
81+
| 1 | Gauge | Double | Deprecated |
8282
8383
#### Attributes
8484
@@ -93,9 +93,9 @@ metrics:
9393
9494
[DEPRECATED] Gauge double metric disabled by default.
9595
96-
| Unit | Metric Type | Value Type |
97-
| ---- | ----------- | ---------- |
98-
| | Gauge | Double |
96+
| Unit | Metric Type | Value Type | Stability |
97+
| ---- | ----------- | ---------- | --------- |
98+
| | Gauge | Double | Deprecated |
9999
100100
#### Attributes
101101
@@ -190,19 +190,19 @@ The following telemetry is emitted by this component.
190190
191191
### otelcol_batch_size_trigger_send
192192
193-
Number of times the batch was sent due to a size trigger [deprecated since v0.110.0]
193+
Number of times the batch was sent due to a size trigger [Deprecated since v0.110.0]
194194
195195
| Unit | Metric Type | Value Type | Monotonic | Stability |
196196
| ---- | ----------- | ---------- | --------- | --------- |
197-
| {times} | Sum | Int | true | deprecated |
197+
| {times} | Sum | Int | true | Deprecated |
198198
199199
### otelcol_process_runtime_total_alloc_bytes
200200
201201
Cumulative bytes allocated for heap objects (see 'go doc runtime.MemStats.TotalAlloc')
202202
203203
| Unit | Metric Type | Value Type | Monotonic | Stability |
204204
| ---- | ----------- | ---------- | --------- | --------- |
205-
| By | Sum | Int | true | stable |
205+
| By | Sum | Int | true | Stable |
206206
207207
### otelcol_queue_capacity
208208
@@ -214,18 +214,18 @@ Queue capacity - sync gauge example.
214214
215215
### otelcol_queue_length
216216
217-
This metric is optional and therefore not initialized in NewTelemetryBuilder. [alpha]
217+
This metric is optional and therefore not initialized in NewTelemetryBuilder. [Alpha]
218218
219219
For example this metric only exists if feature A is enabled.
220220
221221
| Unit | Metric Type | Value Type | Stability |
222222
| ---- | ----------- | ---------- | --------- |
223-
| {items} | Gauge | Int | alpha |
223+
| {items} | Gauge | Int | Alpha |
224224
225225
### otelcol_request_duration
226226
227-
Duration of request [alpha]
227+
Duration of request [Alpha]
228228
229229
| Unit | Metric Type | Value Type | Stability |
230230
| ---- | ----------- | ---------- | --------- |
231-
| s | Histogram | Double | alpha |
231+
| s | Histogram | Double | Alpha |

cmd/mdatagen/internal/samplereceiver/internal/metadata/generated_telemetry.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)