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.
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 inopentelemetry-collector/cmd/mdatagen/internal/metadata.go
Lines 795 to 829 in f1f655b
md.Attributesandmd.Metrics. Hence it does not covermd.ResourceAttributes.As a result, components that declare
semantic_convention.refunderresource_attributesin theirmetadata.yamlget broken relative links in the generateddocumentation.mdinstead of fully-qualified URLs.Current behaviour:
Given a
metadata.yamlwithsem_conv_version: 1.41.0and:The generated
documentation.mdrenders[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.refentries to thek8sattributesprocessor of opentelemetry-collector-contrib: open-telemetry/opentelemetry-collector-contrib#48460Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding
+1orme too, to help us triage it. Learn more here.