Skip to content

[mdatagen] expandSemConvRefs() does not expand semantic_convention.ref for resource_attributes #15313

Description

@ChrsMark

Component(s)

cmd/mdatagen

Describe the issue you're reporting

PR #14646 added automatic expansion of relative semantic_convention.ref paths to full semconv GitHub URLs. However, the expandSemConvRefs() function in

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
}
only iterates over md.Attributes and md.Metrics. Hence it does not cover md.ResourceAttributes.

As a result, components that declare semantic_convention.ref under resource_attributes in their metadata.yaml get broken relative links in the generated documentation.md instead of fully-qualified URLs.

Current behaviour:

Given a metadata.yaml with sem_conv_version: 1.41.0 and:

  resource_attributes:
    k8s.deployment.name:
      semantic_convention:
        ref: k8s.md#k8s-deployment-name

The generated documentation.md renders [k8s.deployment.name](k8s.md#k8s-deployment-name).

Expected behaviour:

Should render the same as expanded Attributes/Metrics refs:

[k8s.deployment.name](https://github.com/open-telemetry/semantic-conventions/blob/v1.41.0/docs/registry/attributes/k8s.md#k8s-deployment-name)

Discovered while adding semantic_convention.ref entries to the k8sattributes processor of opentelemetry-collector-contrib: open-telemetry/opentelemetry-collector-contrib#48460

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions