From 2d8af22cd8197129e3fe1e16c47bcfb61fc3dc54 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Thu, 21 May 2026 10:28:00 +0200 Subject: [PATCH 1/3] feat(docs): Add links to deprecated and aliased attributes --- docs/src/components/AttributeCard.astro | 8 +++++--- docs/src/pages/measurements/index.astro | 11 ++--------- docs/src/pages/names/index.astro | 9 +++++---- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/docs/src/components/AttributeCard.astro b/docs/src/components/AttributeCard.astro index 6550f9ce..202d1945 100644 --- a/docs/src/components/AttributeCard.astro +++ b/docs/src/components/AttributeCard.astro @@ -3,6 +3,8 @@ import PiiBadge from './PiiBadge.astro'; import VisibilityBadge from './VisibilityBadge.astro'; import OtelBadge from './OtelBadge.astro'; import TypeBadge from './TypeBadge.astro'; +import AttributeLink from './AttributeLink.astro'; +import LinkedBrief from './LinkedBrief.astro'; import type { Attribute } from '../content.config'; import { parseAttributeId } from '../utils/category'; @@ -55,7 +57,7 @@ const rawJson = JSON.stringify(attribute, null, 2); -

{attribute.brief}

+

{attribute.pii.reason && ( @@ -76,7 +78,7 @@ const rawJson = JSON.stringify(attribute, null, 2);
Aliases - {attribute.alias.map((a) => {a})} + {attribute.alias.map((a) => )}
)} @@ -102,7 +104,7 @@ const rawJson = JSON.stringify(attribute, null, 2); {isDeprecated && (
{attribute.deprecation?.replacement ? ( -

Use {attribute.deprecation.replacement} instead.

+

Use instead.

) : (

No replacement available at this time.

)} diff --git a/docs/src/pages/measurements/index.astro b/docs/src/pages/measurements/index.astro index 7186cd97..149a9b74 100644 --- a/docs/src/pages/measurements/index.astro +++ b/docs/src/pages/measurements/index.astro @@ -1,5 +1,6 @@ --- import BaseLayout from '../../layouts/BaseLayout.astro'; +import AttributeLink from '../../components/AttributeLink.astro'; import { getCollection } from 'astro:content'; const allMeasurements = await getCollection('measurements'); @@ -18,12 +19,6 @@ for (const measurements of platformMap.values()) { } const sortedPlatforms = Array.from(platformMap.keys()).sort(); - -function attributeUrl(key: string): string { - const category = key.includes('.') ? key.split('.')[0] : 'general'; - const anchor = key.replace(/\./g, '-').replace(//g, ''); - return `${import.meta.env.BASE_URL}attributes/${category}/#${anchor}`; -} --- @@ -80,9 +75,7 @@ function attributeUrl(key: string): string { {m.data.attribute ? ( - - {m.data.attribute} - + ) : ( )} diff --git a/docs/src/pages/names/index.astro b/docs/src/pages/names/index.astro index 4b5de2ef..719dec16 100644 --- a/docs/src/pages/names/index.astro +++ b/docs/src/pages/names/index.astro @@ -1,6 +1,7 @@ --- import BaseLayout from '../../layouts/BaseLayout.astro'; import CategoryChip from '../../components/CategoryChip.astro'; +import LinkedTemplate from '../../components/LinkedTemplate.astro'; import { getCollection } from 'astro:content'; // Get all name definitions @@ -107,13 +108,13 @@ const totalOperations = allNames.reduce((acc, name) => acc + name.data.operation

Templates

    - {op.templates.map((template, index) => ( + {op.templates.map((tmpl, index) => (
  1. {template} - {index === op.templates.length - 1 && !template.includes('{{') && ( + index === op.templates.length - 1 && !tmpl.includes('{{') ? 'border border-accent' : '' + ]}> + {index === op.templates.length - 1 && !tmpl.includes('{{') && ( fallback )}
  2. From e8d7f665049a578115e44d0e47692cc2ab0bb6be Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Thu, 21 May 2026 10:36:03 +0200 Subject: [PATCH 2/3] remove linkedBrief, fix LinkedTemplate rendering for span names --- docs/src/components/AttributeCard.astro | 3 +- docs/src/components/AttributeLink.astro | 12 ++++++ docs/src/components/LinkedTemplate.astro | 50 ++++++++++++++++++++++++ docs/src/utils/attributeUrl.ts | 11 ++++++ 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 docs/src/components/AttributeLink.astro create mode 100644 docs/src/components/LinkedTemplate.astro create mode 100644 docs/src/utils/attributeUrl.ts diff --git a/docs/src/components/AttributeCard.astro b/docs/src/components/AttributeCard.astro index 202d1945..dba99359 100644 --- a/docs/src/components/AttributeCard.astro +++ b/docs/src/components/AttributeCard.astro @@ -4,7 +4,6 @@ import VisibilityBadge from './VisibilityBadge.astro'; import OtelBadge from './OtelBadge.astro'; import TypeBadge from './TypeBadge.astro'; import AttributeLink from './AttributeLink.astro'; -import LinkedBrief from './LinkedBrief.astro'; import type { Attribute } from '../content.config'; import { parseAttributeId } from '../utils/category'; @@ -57,7 +56,7 @@ const rawJson = JSON.stringify(attribute, null, 2);
-

+

{attribute.brief}

{attribute.pii.reason && ( diff --git a/docs/src/components/AttributeLink.astro b/docs/src/components/AttributeLink.astro new file mode 100644 index 00000000..f23e09d9 --- /dev/null +++ b/docs/src/components/AttributeLink.astro @@ -0,0 +1,12 @@ +--- +import { attributeUrl } from '../utils/attributeUrl'; + +interface Props { + name: string; +} + +const { name } = Astro.props; +const href = attributeUrl(name, import.meta.env.BASE_URL); +--- + +{name} diff --git a/docs/src/components/LinkedTemplate.astro b/docs/src/components/LinkedTemplate.astro new file mode 100644 index 00000000..3650709d --- /dev/null +++ b/docs/src/components/LinkedTemplate.astro @@ -0,0 +1,50 @@ +--- +/** + * Renders a span name template string, turning `{{attribute.key}}` + * placeholders into clickable links to the corresponding attribute page. + */ +import { attributeUrl } from '../utils/attributeUrl'; + +interface Props { + template: string; +} + +const { template } = Astro.props; + +const PLACEHOLDER = /\{\{([^}]+)\}\}/g; + +interface Segment { + type: 'text' | 'link'; + value: string; +} + +const segments: Segment[] = []; +let lastIndex = 0; +let match: RegExpExecArray | null; + +while ((match = PLACEHOLDER.exec(template)) !== null) { + if (match.index > lastIndex) { + segments.push({ type: 'text', value: template.slice(lastIndex, match.index) }); + } + segments.push({ type: 'link', value: match[1] }); + lastIndex = match.index + match[0].length; +} + +if (lastIndex < template.length) { + segments.push({ type: 'text', value: template.slice(lastIndex) }); +} + +const hasPlaceholders = segments.some((s) => s.type === 'link'); +--- + +{hasPlaceholders ? ( + segments.map((seg) => + seg.type === 'link' ? ( + {`{{${seg.value}}}`} + ) : ( + {seg.value} + ) + ) +) : ( + {template} +)} diff --git a/docs/src/utils/attributeUrl.ts b/docs/src/utils/attributeUrl.ts new file mode 100644 index 00000000..24a056c7 --- /dev/null +++ b/docs/src/utils/attributeUrl.ts @@ -0,0 +1,11 @@ +/** + * Builds a URL to an attribute's anchor on the docs site. + * Derives the category from the first segment of a dotted key + * (e.g. "http.request.method" → category "http"). + * Keys without a dot land in the "general" category. + */ +export function attributeUrl(key: string, base: string): string { + const category = key.includes('.') ? key.split('.')[0] : 'general'; + const anchor = key.replace(/\./g, '-').replace(//g, ''); + return `${base}attributes/${category}/#${anchor}`; +} From cbe5071ba45badae4397534cc3a89257344615d4 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Thu, 21 May 2026 10:42:19 +0200 Subject: [PATCH 3/3] fix linting error --- docs/src/components/LinkedTemplate.astro | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/src/components/LinkedTemplate.astro b/docs/src/components/LinkedTemplate.astro index 3650709d..08e6ffba 100644 --- a/docs/src/components/LinkedTemplate.astro +++ b/docs/src/components/LinkedTemplate.astro @@ -20,9 +20,8 @@ interface Segment { const segments: Segment[] = []; let lastIndex = 0; -let match: RegExpExecArray | null; -while ((match = PLACEHOLDER.exec(template)) !== null) { +for (const match of template.matchAll(PLACEHOLDER)) { if (match.index > lastIndex) { segments.push({ type: 'text', value: template.slice(lastIndex, match.index) }); }