Skip to content

Commit 6507ad0

Browse files
dmathieucodeboten
andauthored
Use component.StabilityLevel for entity stability (#14425)
Right now, the entity is using `string` for its stability field, which prevents validating that the value is within the enum. This changes it to a `component.StabilityLevel`. --------- Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
1 parent 8ba3ae3 commit 6507ad0

File tree

5 files changed

+60
-2
lines changed

5 files changed

+60
-2
lines changed
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: Validate stability level for entities
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [14425]
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/metadata.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"strconv"
1212
"strings"
1313

14+
"go.opentelemetry.io/collector/component"
1415
"go.opentelemetry.io/collector/filter"
1516
"go.opentelemetry.io/collector/pdata/pcommon"
1617
)
@@ -628,7 +629,7 @@ type Entity struct {
628629
// Brief is a brief description of the entity.
629630
Brief string `mapstructure:"brief"`
630631
// Stability is the stability level of the entity.
631-
Stability string `mapstructure:"stability"`
632+
Stability component.StabilityLevel `mapstructure:"stability"`
632633
// Identity contains references to resource attributes that uniquely identify the entity.
633634
Identity []EntityAttributeRef `mapstructure:"identity"`
634635
// Description contains references to resource attributes that describe the entity.

cmd/mdatagen/internal/metadata_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ func TestValidate(t *testing.T) {
140140
name: "testdata/entity_duplicate_types.yaml",
141141
wantErr: `duplicate entity type: host`,
142142
},
143+
{
144+
name: "testdata/invalid_entity_stability.yaml",
145+
wantErr: `unsupported stability level: "stable42"`,
146+
},
143147
}
144148
for _, tt := range tests {
145149
t.Run(tt.name, func(t *testing.T) {

cmd/mdatagen/internal/sampleconnector/documentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ The following entities are defined for this component:
137137
138138
A test entity.
139139
140-
**Stability:** stable
140+
**Stability:** Stable
141141
142142
**Identifying Attributes:**
143143
- `string.resource.attr`
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
type: sample
2+
status:
3+
class: receiver
4+
stability:
5+
stable: [metrics]
6+
7+
resource_attributes:
8+
host.id:
9+
description: The unique host identifier
10+
type: string
11+
enabled: true
12+
host.name:
13+
description: The hostname
14+
type: string
15+
enabled: true
16+
process.pid:
17+
description: The process identifier
18+
type: int
19+
enabled: true
20+
21+
entities:
22+
- type: host
23+
brief: A host instance.
24+
stability: stable42
25+
identity:
26+
- ref: host.id
27+
description:
28+
- ref: host.name

0 commit comments

Comments
 (0)