Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/validate-entity-stability.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: Validate stability level for entities

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

# (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: []
3 changes: 2 additions & 1 deletion cmd/mdatagen/internal/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strconv"
"strings"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/filter"
"go.opentelemetry.io/collector/pdata/pcommon"
)
Expand Down Expand Up @@ -628,7 +629,7 @@ type Entity struct {
// Brief is a brief description of the entity.
Brief string `mapstructure:"brief"`
// Stability is the stability level of the entity.
Stability string `mapstructure:"stability"`
Stability component.StabilityLevel `mapstructure:"stability"`
// Identity contains references to resource attributes that uniquely identify the entity.
Identity []EntityAttributeRef `mapstructure:"identity"`
// Description contains references to resource attributes that describe the entity.
Expand Down
4 changes: 4 additions & 0 deletions cmd/mdatagen/internal/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ func TestValidate(t *testing.T) {
name: "testdata/entity_duplicate_types.yaml",
wantErr: `duplicate entity type: host`,
},
{
name: "testdata/invalid_entity_stability.yaml",
wantErr: `unsupported stability level: "stable42"`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/mdatagen/internal/sampleconnector/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ The following entities are defined for this component:

A test entity.

**Stability:** stable
**Stability:** Stable
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change means the generated doc now capitalized the stability. I can lowercase, but this feels more readable to me.


**Identifying Attributes:**
- `string.resource.attr`
Expand Down
28 changes: 28 additions & 0 deletions cmd/mdatagen/internal/testdata/invalid_entity_stability.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
type: sample
status:
class: receiver
stability:
stable: [metrics]

resource_attributes:
host.id:
description: The unique host identifier
type: string
enabled: true
host.name:
description: The hostname
type: string
enabled: true
process.pid:
description: The process identifier
type: int
enabled: true

entities:
- type: host
brief: A host instance.
stability: stable42
identity:
- ref: host.id
description:
- ref: host.name
Loading