Skip to content

Commit 21ef5d9

Browse files
authored
[cmd/mdatagen] Add stability field to resource attributes (#15371)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Adds support for defining stability levels for resource attributes in `cmd/mdatagen`. <!-- Issue number if applicable --> #### Link to tracking issue Fixes #15312 <!--Describe what testing was performed and which tests were added.--> #### Testing - Added cmd/mdatagen/internal/testdata/invalid_rattr_stability.yaml as a test fixture - Added a test case in metadata_test.go that verifies an invalid stability value produces the correct error - Ran go test ./internal/... and all tests passed <!--Describe the documentation added.--> #### Documentation - Added stability under resource attributes in metadata-schema.yaml <!--Authorship attestation. See AGENTS.md for details. AI agents must not check this box on behalf of the user; the human author must check it themselves before the PR is ready for review.--> #### Authorship - [x] I, a human, wrote this pull request description myself. <!--Please delete paragraphs that you did not use before submitting.-->
1 parent effb9b0 commit 21ef5d9

14 files changed

Lines changed: 126 additions & 51 deletions

File tree

.chloggen/main.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp)
7+
component: cmd/mdatagen
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add support for defining stability levels for resource attributes
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [15312]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: []

cmd/mdatagen/internal/loader_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ func TestLoadMetadata(t *testing.T) {
131131
},
132132
FullName: "optional.resource.attr",
133133
RequirementLevel: AttributeRequirementLevelRecommended,
134+
Stability: component.StabilityLevelDevelopment,
134135
},
135136
"slice.resource.attr": {
136137
Description: "Resource attribute with a slice value.",
@@ -140,6 +141,7 @@ func TestLoadMetadata(t *testing.T) {
140141
},
141142
FullName: "slice.resource.attr",
142143
RequirementLevel: AttributeRequirementLevelRecommended,
144+
Stability: component.StabilityLevelDevelopment,
143145
},
144146
"map.resource.attr": {
145147
Description: "Resource attribute with a map value.",
@@ -149,6 +151,7 @@ func TestLoadMetadata(t *testing.T) {
149151
},
150152
FullName: "map.resource.attr",
151153
RequirementLevel: AttributeRequirementLevelRecommended,
154+
Stability: component.StabilityLevelDevelopment,
152155
},
153156
"string.resource.attr_disable_warning": {
154157
Description: "Resource attribute with any string value.",

cmd/mdatagen/internal/metadata.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,8 @@ type Attribute struct {
639639
RequirementLevel AttributeRequirementLevel `mapstructure:"requirement_level"`
640640
// The semantic convention reference of the attribute.
641641
SemanticConvention *SemanticConvention `mapstructure:"semantic_convention"`
642+
// Stability is the stability level of the resource attribute.
643+
Stability component.StabilityLevel `mapstructure:"stability"`
642644
}
643645

644646
// IsConditional returns true if the attribute is conditionally required.

cmd/mdatagen/internal/metadata_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ func TestValidate(t *testing.T) {
7575
name: "testdata/no_type_rattr.yaml",
7676
wantErr: "empty type for resource attribute: string.resource.attr",
7777
},
78+
{
79+
name: "testdata/rattr_stability_valid.yaml",
80+
wantErr: "",
81+
},
82+
{
83+
name: "testdata/invalid_rattr_stability.yaml",
84+
wantErr: `unsupported stability level: "test42"`,
85+
},
7886
{
7987
name: "testdata/no_metric_description.yaml",
8088
wantErr: "metric \"default.metric\": missing metric description",

cmd/mdatagen/internal/sampleconnector/documentation.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,16 @@ metrics:
124124
125125
## Resource Attributes
126126
127-
| Name | Description | Values | Enabled | Semantic Convention |
128-
| ---- | ----------- | ------ | ------- | ------------------- |
129-
| map.resource.attr | Resource attribute with a map value. | Any Map | true | - |
130-
| optional.resource.attr | Explicitly disabled ResourceAttribute. | Any Str | false | - |
131-
| slice.resource.attr | Resource attribute with a slice value. | Any Slice | true | - |
132-
| string.enum.resource.attr | Resource attribute with a known set of string values. | Str: ``one``, ``two`` | true | - |
133-
| string.resource.attr | Resource attribute with any string value. | Any Str | true | - |
134-
| string.resource.attr_disable_warning | Resource attribute with any string value. | Any Str | true | - |
135-
| string.resource.attr_remove_warning | Resource attribute with any string value. | Any Str | false | - |
136-
| string.resource.attr_to_be_removed | Resource attribute with any string value. | Any Str | true | - |
127+
| Name | Description | Values | Enabled | Semantic Convention | Stability |
128+
| ---- | ----------- | ------ | ------- | ------------------- | --------- |
129+
| map.resource.attr | Resource attribute with a map value. | Any Map | true | - | - |
130+
| optional.resource.attr | Explicitly disabled ResourceAttribute. | Any Str | false | - | - |
131+
| slice.resource.attr | Resource attribute with a slice value. | Any Slice | true | - | - |
132+
| string.enum.resource.attr | Resource attribute with a known set of string values. | Str: ``one``, ``two`` | true | - | - |
133+
| string.resource.attr | Resource attribute with any string value. | Any Str | true | - | - |
134+
| string.resource.attr_disable_warning | Resource attribute with any string value. | Any Str | true | - | - |
135+
| string.resource.attr_remove_warning | Resource attribute with any string value. | Any Str | false | - | - |
136+
| string.resource.attr_to_be_removed | Resource attribute with any string value. | Any Str | true | - | - |
137137
138138
## Entities
139139

cmd/mdatagen/internal/sampleentityreceiver/documentation.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ Number of desired replicas
4444
4545
## Resource Attributes
4646
47-
| Name | Description | Values | Enabled | Semantic Convention |
48-
| ---- | ----------- | ------ | ------- | ------------------- |
49-
| k8s.namespace.name | The name of the Kubernetes Namespace | Any Str | true | - |
50-
| k8s.pod.name | The name of the Kubernetes Pod | Any Str | true | - |
51-
| k8s.pod.uid | The UID of the Kubernetes Pod | Any Str | true | - |
52-
| k8s.replicaset.name | The name of the Kubernetes ReplicaSet | Any Str | true | - |
53-
| k8s.replicaset.uid | The UID of the Kubernetes ReplicaSet | Any Str | true | - |
47+
| Name | Description | Values | Enabled | Semantic Convention | Stability |
48+
| ---- | ----------- | ------ | ------- | ------------------- | --------- |
49+
| k8s.namespace.name | The name of the Kubernetes Namespace | Any Str | true | - | - |
50+
| k8s.pod.name | The name of the Kubernetes Pod | Any Str | true | - | - |
51+
| k8s.pod.uid | The UID of the Kubernetes Pod | Any Str | true | - | - |
52+
| k8s.replicaset.name | The name of the Kubernetes ReplicaSet | Any Str | true | - | - |
53+
| k8s.replicaset.uid | The UID of the Kubernetes ReplicaSet | Any Str | true | - | - |
5454
5555
## Entities
5656

cmd/mdatagen/internal/sampleprocessor/documentation.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
## Resource Attributes
66

7-
| Name | Description | Values | Enabled | Semantic Convention |
8-
| ---- | ----------- | ------ | ------- | ------------------- |
9-
| map.resource.attr | Resource attribute with a map value. | Any Map | true | - |
10-
| optional.resource.attr | Explicitly disabled ResourceAttribute. | Any Str | false | - |
11-
| slice.resource.attr | Resource attribute with a slice value. | Any Slice | true | - |
12-
| string.enum.resource.attr | Resource attribute with a known set of string values. | Str: ``one``, ``two`` | true | - |
13-
| string.resource.attr | Resource attribute with any string value. | Any Str | true | - |
14-
| string.resource.attr_disable_warning | Resource attribute with any string value. | Any Str | true | - |
15-
| string.resource.attr_remove_warning | Resource attribute with any string value. | Any Str | false | - |
16-
| string.resource.attr_to_be_removed | Resource attribute with any string value. | Any Str | true | - |
7+
| Name | Description | Values | Enabled | Semantic Convention | Stability |
8+
| ---- | ----------- | ------ | ------- | ------------------- | --------- |
9+
| map.resource.attr | Resource attribute with a map value. | Any Map | true | - | - |
10+
| optional.resource.attr | Explicitly disabled ResourceAttribute. | Any Str | false | - | - |
11+
| slice.resource.attr | Resource attribute with a slice value. | Any Slice | true | - | - |
12+
| string.enum.resource.attr | Resource attribute with a known set of string values. | Str: ``one``, ``two`` | true | - | - |
13+
| string.resource.attr | Resource attribute with any string value. | Any Str | true | - | - |
14+
| string.resource.attr_disable_warning | Resource attribute with any string value. | Any Str | true | - | - |
15+
| string.resource.attr_remove_warning | Resource attribute with any string value. | Any Str | false | - | - |
16+
| string.resource.attr_to_be_removed | Resource attribute with any string value. | Any Str | true | - | - |

cmd/mdatagen/internal/samplereceiver/documentation.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -244,17 +244,17 @@ The event will be renamed soon.
244244
245245
## Resource Attributes
246246
247-
| Name | Description | Values | Enabled | Semantic Convention |
248-
| ---- | ----------- | ------ | ------- | ------------------- |
249-
| map.resource.attr | Resource attribute with a map value. | Any Map | true | - |
250-
| optional.resource.attr | Explicitly disabled ResourceAttribute. | Any Str | false | - |
251-
| slice.resource.attr | Resource attribute with a slice value. | Any Slice | true | - |
252-
| string.enum.resource.attr | Resource attribute with a known set of string values. | Str: ``one``, ``two`` | true | - |
253-
| string.resource.attr | Resource attribute with any string value. | Any Str | true | - |
254-
| string.resource.attr_disable_warning | Resource attribute with any string value. | Any Str | true | - |
255-
| string.resource.attr_remove_warning | Resource attribute with any string value. | Any Str | false | - |
256-
| string.resource.attr_to_be_removed | Resource attribute with any string value. | Any Str | true | - |
257-
| string.resource.disabled_attr_to_be_removed | Resource attribute with any string value. | Any Str | false | - |
247+
| Name | Description | Values | Enabled | Semantic Convention | Stability |
248+
| ---- | ----------- | ------ | ------- | ------------------- | --------- |
249+
| map.resource.attr | Resource attribute with a map value. | Any Map | true | - | Development |
250+
| optional.resource.attr | Explicitly disabled ResourceAttribute. | Any Str | false | - | Development |
251+
| slice.resource.attr | Resource attribute with a slice value. | Any Slice | true | - | Development |
252+
| string.enum.resource.attr | Resource attribute with a known set of string values. | Str: ``one``, ``two`` | true | - | - |
253+
| string.resource.attr | Resource attribute with any string value. | Any Str | true | - | - |
254+
| string.resource.attr_disable_warning | Resource attribute with any string value. | Any Str | true | - | - |
255+
| string.resource.attr_remove_warning | Resource attribute with any string value. | Any Str | false | - | - |
256+
| string.resource.attr_to_be_removed | Resource attribute with any string value. | Any Str | true | - | - |
257+
| string.resource.disabled_attr_to_be_removed | Resource attribute with any string value. | Any Str | false | - | - |
258258
259259
## Internal Telemetry
260260

cmd/mdatagen/internal/samplereceiver/metadata.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,19 @@ resource_attributes:
6262
description: Resource attribute with a map value.
6363
type: map
6464
enabled: true
65+
stability: development
6566

6667
optional.resource.attr:
6768
description: Explicitly disabled ResourceAttribute.
6869
type: string
6970
enabled: false
71+
stability: development
7072

7173
slice.resource.attr:
7274
description: Resource attribute with a slice value.
7375
type: slice
7476
enabled: true
77+
stability: development
7578

7679
string.enum.resource.attr:
7780
description: Resource attribute with a known set of string values.

cmd/mdatagen/internal/samplescraper/documentation.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ metrics:
134134
135135
## Resource Attributes
136136
137-
| Name | Description | Values | Enabled | Semantic Convention |
138-
| ---- | ----------- | ------ | ------- | ------------------- |
139-
| map.resource.attr | Resource attribute with a map value. | Any Map | true | - |
140-
| optional.resource.attr | Explicitly disabled ResourceAttribute. | Any Str | false | - |
141-
| slice.resource.attr | Resource attribute with a slice value. | Any Slice | true | - |
142-
| string.enum.resource.attr | Resource attribute with a known set of string values. | Str: ``one``, ``two`` | true | - |
143-
| string.resource.attr | Resource attribute with any string value. | Any Str | true | - |
144-
| string.resource.attr_disable_warning | Resource attribute with any string value. | Any Str | true | - |
145-
| string.resource.attr_remove_warning | Resource attribute with any string value. | Any Str | false | - |
146-
| string.resource.attr_to_be_removed | Resource attribute with any string value. | Any Str | true | - |
137+
| Name | Description | Values | Enabled | Semantic Convention | Stability |
138+
| ---- | ----------- | ------ | ------- | ------------------- | --------- |
139+
| map.resource.attr | Resource attribute with a map value. | Any Map | true | - | - |
140+
| optional.resource.attr | Explicitly disabled ResourceAttribute. | Any Str | false | - | - |
141+
| slice.resource.attr | Resource attribute with a slice value. | Any Slice | true | - | - |
142+
| string.enum.resource.attr | Resource attribute with a known set of string values. | Str: ``one``, ``two`` | true | - | - |
143+
| string.resource.attr | Resource attribute with any string value. | Any Str | true | - | - |
144+
| string.resource.attr_disable_warning | Resource attribute with any string value. | Any Str | true | - | - |
145+
| string.resource.attr_remove_warning | Resource attribute with any string value. | Any Str | false | - | - |
146+
| string.resource.attr_to_be_removed | Resource attribute with any string value. | Any Str | true | - | - |

0 commit comments

Comments
 (0)