Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
7525a1e
Add metadata attributes semconv refs in mdatagen
osullivandonal Feb 25, 2026
cf31d7e
Add chlog for adding semconv reference for attributes in mdatagen
osullivandonal Feb 26, 2026
9ef31f4
Add unreclaimable to cspell check
osullivandonal Feb 26, 2026
c0ce1b7
Update mdatagen attribute and metric semantic-conventions ref
osullivandonal Feb 27, 2026
059df13
Update cspell with systemcputime and systemdiskio
osullivandonal Feb 27, 2026
5a77755
Merge branch 'main' into mdatagen-add-attribute-semconv-refs
osullivandonal Mar 3, 2026
6d1eb62
Create a separate column for semantic-conventions ref for attributes
osullivandonal Mar 4, 2026
3d4c6fd
Merge branch 'main' into mdatagen-add-attribute-semconv-refs
osullivandonal Mar 4, 2026
cf11e95
Update chlog with make generate-chloggen-components as per PR check
osullivandonal Mar 4, 2026
6fe82d4
Update documentation template to use "-" for empty semconv ref values
osullivandonal Mar 5, 2026
cc65747
Add full semantic-conventions ref url example in metadata-schema
osullivandonal Mar 5, 2026
a6972ba
Merge branch 'main' into mdatagen-add-attribute-semconv-refs
osullivandonal Mar 5, 2026
5a839de
Remove debug line from expandSemConvRefs function
osullivandonal Mar 6, 2026
8aba9e5
Merge branch 'main' into mdatagen-add-attribute-semconv-refs
osullivandonal Mar 6, 2026
cda1006
Update mdatagen samplereceiver with make gogenerate
osullivandonal Mar 6, 2026
6234e2d
Merge branch 'main' into mdatagen-add-attribute-semconv-refs
osullivandonal Mar 9, 2026
b7dc46e
Merge branch 'main' into mdatagen-add-attribute-semconv-refs
osullivandonal Mar 10, 2026
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/mdatagen-add-attribute-semconv-refs.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: Add semconv reference for attributes

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

# (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: [user]
3 changes: 3 additions & 0 deletions .github/workflows/utils/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@
"subpackages",
"swiatekm",
"syft",
"systemcputime",
"systemdiskio",
"tailsampling",
"tchannel",
"telemetrygen",
Expand Down Expand Up @@ -494,6 +496,7 @@
"unmarshal",
"unmarshalling",
"unmarshalls",
"unreclaimable",
"unredacted",
"unshallow",
"unstarted",
Expand Down
4 changes: 4 additions & 0 deletions cmd/mdatagen/internal/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ func LoadMetadata(filePath string) (Metadata, error) {
md.GeneratedPackageName = "metadata"
}

if err := md.expandSemConvRefs(); err != nil {
return md, err
}

if err := md.Validate(); err != nil {
return md, err
}
Expand Down
47 changes: 46 additions & 1 deletion cmd/mdatagen/internal/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ func TestLoadMetadata(t *testing.T) {
},

Attributes: map[AttributeName]Attribute{
"cpu": {
Description: "Logical CPU number starting at 0.",
Type: ValueType{
ValueType: pcommon.ValueTypeStr,
},
FullName: "cpu",
RequirementLevel: AttributeRequirementLevelRecommended,
},
"enum_attr": {
Description: "Attribute with a known set of string values.",
NameOverride: "",
Expand Down Expand Up @@ -275,6 +283,18 @@ func TestLoadMetadata(t *testing.T) {
FullName: "required_string_attr",
RequirementLevel: AttributeRequirementLevelRequired,
},
"state": {
Description: "Breakdown of memory usage by type.",
Enum: []string{"buffered", "cached", "inactive", "free", "slab_reclaimable", "slab_unreclaimable", "used"},
Type: ValueType{
ValueType: pcommon.ValueTypeStr,
},
FullName: "state",
RequirementLevel: AttributeRequirementLevelRecommended,
SemanticConvention: &SemanticConvention{
SemanticConventionRef: "https://github.com/open-telemetry/semantic-conventions/blob/v1.38.0/docs/registry/attributes/system.md#system-memory-state",
},
},
},
Metrics: map[MetricName]Metric{
"default.metric": {
Expand Down Expand Up @@ -330,6 +350,7 @@ func TestLoadMetadata(t *testing.T) {
SemanticConvention: &SemanticConvention{SemanticConventionRef: "https://github.com/open-telemetry/semantic-conventions/blob/v1.38.0/docs/system/system-metrics.md#metric-systemcputime"},
Description: "Monotonic cumulative sum int metric enabled by default.",
ExtendedDocumentation: "The metric will be become optional soon.",
Attributes: []AttributeName{"cpu"},
},
Unit: strPtr("s"),
Sum: &Sum{
Expand All @@ -338,6 +359,20 @@ func TestLoadMetadata(t *testing.T) {
Mono: Mono{Monotonic: true},
},
},
"system.memory.usage": {
Signal: Signal{
Enabled: true,
Stability: component.StabilityLevelDevelopment,
Description: "Bytes of memory in use.",
Attributes: []AttributeName{"state"},
},
Unit: strPtr("By"),
Sum: &Sum{
MetricValueType: MetricValueType{pmetric.NumberDataPointValueTypeInt},
AggregationTemporality: AggregationTemporality{Aggregation: pmetric.AggregationTemporalityCumulative},
Mono: Mono{Monotonic: false},
},
},
"optional.metric": {
Signal: Signal{
Enabled: false,
Expand Down Expand Up @@ -629,7 +664,7 @@ func TestLoadMetadata(t *testing.T) {
{
name: "testdata/invalid_metric_semconvref.yaml",
want: Metadata{},
wantErr: "metric \"default.metric\": invalid semantic-conventions URL: want https://github.com/open-telemetry/semantic-conventions/blob/v1.37.2/*#metric-defaultmetric, got \"https://github.com/open-telemetry/semantic-conventions/blob/v1.38.0/docs/system/system-metrics.md#metric-systemcputime\"",
wantErr: "metric \"default.metric\": invalid semantic-conventions URL: want https://github.com/open-telemetry/semantic-conventions/blob/v1.37.2/*#metric-defaultmetric, got \"https://github.com/open-telemetry/semantic-conventions/blob/v1.37.2/docs/system/system-metrics.md#metric-systemcputime\"",
},
{
name: "testdata/no_metric_stability.yaml",
Expand All @@ -646,6 +681,16 @@ func TestLoadMetadata(t *testing.T) {
want: Metadata{},
wantErr: "config type must be \"object\", got \"string\"",
},
{
name: "testdata/invalid_metric_semconv_url_full.yaml",
want: Metadata{},
wantErr: "metric \"default.metric\", use relative path for URL, not the full URL",
},
{
name: "testdata/invalid_attribute_semconv_url_full.yaml",
want: Metadata{},
wantErr: "attribute \"used_attr\", use relative path for URL, not the full URL",
},
{
name: "testdata/~~this file doesn't exist~~.yaml",
wantErr: "unable to read the file file:testdata/~~this file doesn't exist~~.yaml",
Expand Down
40 changes: 40 additions & 0 deletions cmd/mdatagen/internal/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"go.opentelemetry.io/collector/pdata/pcommon"
)

const semConvURL = "https://github.com/open-telemetry/semantic-conventions/blob"
Copy link
Member

Choose a reason for hiding this comment

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

While I agree that not having to specify a full URL every time, this assumes all semantic conventions are on the semantic-conventions repository, which may be problematic in the future with open-telemetry/opentelemetry-specification#4906

Copy link
Member

Choose a reason for hiding this comment

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

I think we can proceed with this as is now and revisit once things are more clear in general about how we will link/define semconv and registries in Collector components in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me.


type Metadata struct {
// Type of the component.
Type string `mapstructure:"type"`
Expand Down Expand Up @@ -576,6 +578,8 @@ type Attribute struct {
Warnings Warnings `mapstructure:"warnings"`
// RequirementLevel defines the requirement level of the attribute.
RequirementLevel AttributeRequirementLevel `mapstructure:"requirement_level"`
// The semantic convention reference of the attribute.
SemanticConvention *SemanticConvention `mapstructure:"semantic_convention"`
}

// IsConditional returns true if the attribute is conditionally required.
Expand Down Expand Up @@ -776,3 +780,39 @@ type FeatureGate struct {
// ReferenceURL is the URL with contextual information about the feature gate.
ReferenceURL string `mapstructure:"reference_url"`
}

func (md *Metadata) expandSemConvRefs() error {
for k, v := range md.Attributes {
if v.SemanticConvention != nil {
if strings.HasPrefix(v.SemanticConvention.SemanticConventionRef, "http") {
return fmt.Errorf("attribute %q, use relative path for URL, not the full URL", k)
}
url := fmt.Sprintf(
"%s/v%s/docs/registry/attributes/%s",
semConvURL,
md.SemConvVersion,
v.SemanticConvention.SemanticConventionRef,
)
v.SemanticConvention.SemanticConventionRef = url
}
md.Attributes[k] = v
}

for k, v := range md.Metrics {
if v.SemanticConvention != nil {
if strings.HasPrefix(v.SemanticConvention.SemanticConventionRef, "http") {
return fmt.Errorf("metric %q, use relative path for URL, not the full URL", k)
}
url := fmt.Sprintf(
"%s/v%s/docs/%s",
semConvURL,
md.SemConvVersion,
v.SemanticConvention.SemanticConventionRef,
)
v.SemanticConvention.SemanticConventionRef = url
}
md.Metrics[k] = v
}

return nil
}
74 changes: 37 additions & 37 deletions cmd/mdatagen/internal/sampleconnector/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ The metric will be become optional soon.

#### Attributes

| Name | Description | Values | Requirement Level |
| ---- | ----------- | ------ | -------- |
| string_attr | Attribute with any string value. | Any Str | Recommended |
| state | Integer attribute with overridden name. | Any Int | Recommended |
| enum_attr | Attribute with a known set of string values. | Str: ``red``, ``green``, ``blue`` | Recommended |
| slice_attr | Attribute with a slice value. | Any Slice | Recommended |
| map_attr | Attribute with a map value. | Any Map | Recommended |
| Name | Description | Values | Requirement Level | Semantic Convention |
| ---- | ----------- | ------ | ----------------- | ------------------- |
| string_attr | Attribute with any string value. | Any Str | Recommended | - |
| state | Integer attribute with overridden name. | Any Int | Recommended | - |
| enum_attr | Attribute with a known set of string values. | Str: ``red``, ``green``, ``blue`` | Recommended | - |
| slice_attr | Attribute with a slice value. | Any Slice | Recommended | - |
| map_attr | Attribute with a map value. | Any Map | Recommended | - |

### default.metric.to_be_removed

Expand All @@ -54,13 +54,13 @@ Monotonic cumulative sum int metric with string input_type enabled by default.

#### Attributes

| Name | Description | Values | Requirement Level |
| ---- | ----------- | ------ | -------- |
| string_attr | Attribute with any string value. | Any Str | Recommended |
| state | Integer attribute with overridden name. | Any Int | Recommended |
| enum_attr | Attribute with a known set of string values. | Str: ``red``, ``green``, ``blue`` | Recommended |
| slice_attr | Attribute with a slice value. | Any Slice | Recommended |
| map_attr | Attribute with a map value. | Any Map | Recommended |
| Name | Description | Values | Requirement Level | Semantic Convention |
| ---- | ----------- | ------ | ----------------- | ------------------- |
| string_attr | Attribute with any string value. | Any Str | Recommended | - |
| state | Integer attribute with overridden name. | Any Int | Recommended | - |
| enum_attr | Attribute with a known set of string values. | Str: ``red``, ``green``, ``blue`` | Recommended | - |
| slice_attr | Attribute with a slice value. | Any Slice | Recommended | - |
| map_attr | Attribute with a map value. | Any Map | Recommended | - |

### reaggregate.metric

Expand All @@ -72,10 +72,10 @@ Metric for testing spatial reaggregation

#### Attributes

| Name | Description | Values | Requirement Level |
| ---- | ----------- | ------ | -------- |
| string_attr | Attribute with any string value. | Any Str | Recommended |
| boolean_attr | Attribute with a boolean value. | Any Bool | Recommended |
| Name | Description | Values | Requirement Level | Semantic Convention |
| ---- | ----------- | ------ | ----------------- | ------------------- |
| string_attr | Attribute with any string value. | Any Str | Recommended | - |
| boolean_attr | Attribute with a boolean value. | Any Bool | Recommended | - |

## Optional Metrics

Expand All @@ -99,11 +99,11 @@ metrics:

#### Attributes

| Name | Description | Values | Requirement Level |
| ---- | ----------- | ------ | -------- |
| string_attr | Attribute with any string value. | Any Str | Recommended |
| boolean_attr | Attribute with a boolean value. | Any Bool | Recommended |
| boolean_attr2 | Another attribute with a boolean value. | Any Bool | Recommended |
| Name | Description | Values | Requirement Level | Semantic Convention |
| ---- | ----------- | ------ | ----------------- | ------------------- |
| string_attr | Attribute with any string value. | Any Str | Recommended | - |
| boolean_attr | Attribute with a boolean value. | Any Bool | Recommended | - |
| boolean_attr2 | Another attribute with a boolean value. | Any Bool | Recommended | - |

### optional.metric.empty_unit

Expand All @@ -117,23 +117,23 @@ metrics:

#### Attributes

| Name | Description | Values | Requirement Level |
| ---- | ----------- | ------ | -------- |
| string_attr | Attribute with any string value. | Any Str | Recommended |
| boolean_attr | Attribute with a boolean value. | Any Bool | Recommended |
| Name | Description | Values | Requirement Level | Semantic Convention |
| ---- | ----------- | ------ | ----------------- | ------------------- |
| string_attr | Attribute with any string value. | Any Str | Recommended | - |
| boolean_attr | Attribute with a boolean value. | Any Bool | Recommended | - |

## Resource Attributes

| Name | Description | Values | Enabled |
| ---- | ----------- | ------ | ------- |
| map.resource.attr | Resource attribute with a map value. | Any Map | true |
| optional.resource.attr | Explicitly disabled ResourceAttribute. | Any Str | false |
| slice.resource.attr | Resource attribute with a slice value. | Any Slice | true |
| string.enum.resource.attr | Resource attribute with a known set of string values. | Str: ``one``, ``two`` | true |
| string.resource.attr | Resource attribute with any string value. | Any Str | true |
| string.resource.attr_disable_warning | Resource attribute with any string value. | Any Str | true |
| string.resource.attr_remove_warning | Resource attribute with any string value. | Any Str | false |
| string.resource.attr_to_be_removed | Resource attribute with any string value. | Any Str | true |
| Name | Description | Values | Enabled | Semantic Convention |
| ---- | ----------- | ------ | ------- | ------------------- |
| map.resource.attr | Resource attribute with a map value. | Any Map | true | - |
| optional.resource.attr | Explicitly disabled ResourceAttribute. | Any Str | false | - |
| slice.resource.attr | Resource attribute with a slice value. | Any Slice | true | - |
| string.enum.resource.attr | Resource attribute with a known set of string values. | Str: ``one``, ``two`` | true | - |
| string.resource.attr | Resource attribute with any string value. | Any Str | true | - |
| string.resource.attr_disable_warning | Resource attribute with any string value. | Any Str | true | - |
| string.resource.attr_remove_warning | Resource attribute with any string value. | Any Str | false | - |
| string.resource.attr_to_be_removed | Resource attribute with any string value. | Any Str | true | - |

## Entities

Expand Down
20 changes: 10 additions & 10 deletions cmd/mdatagen/internal/sampleprocessor/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

## Resource Attributes

| Name | Description | Values | Enabled |
| ---- | ----------- | ------ | ------- |
| map.resource.attr | Resource attribute with a map value. | Any Map | true |
| optional.resource.attr | Explicitly disabled ResourceAttribute. | Any Str | false |
| slice.resource.attr | Resource attribute with a slice value. | Any Slice | true |
| string.enum.resource.attr | Resource attribute with a known set of string values. | Str: ``one``, ``two`` | true |
| string.resource.attr | Resource attribute with any string value. | Any Str | true |
| string.resource.attr_disable_warning | Resource attribute with any string value. | Any Str | true |
| string.resource.attr_remove_warning | Resource attribute with any string value. | Any Str | false |
| string.resource.attr_to_be_removed | Resource attribute with any string value. | Any Str | true |
| Name | Description | Values | Enabled | Semantic Convention |
| ---- | ----------- | ------ | ------- | ------------------- |
| map.resource.attr | Resource attribute with a map value. | Any Map | true | - |
| optional.resource.attr | Explicitly disabled ResourceAttribute. | Any Str | false | - |
| slice.resource.attr | Resource attribute with a slice value. | Any Slice | true | - |
| string.enum.resource.attr | Resource attribute with a known set of string values. | Str: ``one``, ``two`` | true | - |
| string.resource.attr | Resource attribute with any string value. | Any Str | true | - |
| string.resource.attr_disable_warning | Resource attribute with any string value. | Any Str | true | - |
| string.resource.attr_remove_warning | Resource attribute with any string value. | Any Str | false | - |
| string.resource.attr_to_be_removed | Resource attribute with any string value. | Any Str | true | - |
54 changes: 54 additions & 0 deletions cmd/mdatagen/internal/samplereceiver/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,60 @@
"description": "SystemCPUTimeConfig provides config for the system.cpu.time metric.",
"type": "object",
"properties": {
"aggregation_strategy": {
"type": "string",
"default": "sum",
"enum": [
"sum",
"avg",
"min",
"max"
]
},
"attributes": {
"type": "array",
"default": [
"cpu"
],
"items": {
"type": "string",
"enum": [
"cpu"
]
}
},
"enabled": {
"type": "boolean",
"default": true
}
}
},
"system.memory.usage": {
"description": "SystemMemoryUsageConfig provides config for the system.memory.usage metric.",
"type": "object",
"properties": {
"aggregation_strategy": {
"type": "string",
"default": "sum",
"enum": [
"sum",
"avg",
"min",
"max"
]
},
"attributes": {
"type": "array",
"default": [
"state"
],
"items": {
"type": "string",
"enum": [
"state"
]
}
},
"enabled": {
"type": "boolean",
"default": true
Expand Down
Loading
Loading