From c88d831c47a13fdab80d5be8acb4b8471cc10724 Mon Sep 17 00:00:00 2001 From: "stefon.simmons" Date: Tue, 5 May 2026 15:31:49 -0400 Subject: [PATCH 1/3] [WEB-8985] Limit mapping-table to OTel name and description columns Co-Authored-By: Claude --- layouts/shortcodes/mapping-table.html | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/layouts/shortcodes/mapping-table.html b/layouts/shortcodes/mapping-table.html index a73efe20bbc..6946e6ba34d 100644 --- a/layouts/shortcodes/mapping-table.html +++ b/layouts/shortcodes/mapping-table.html @@ -1,8 +1,8 @@ -{{/* +{{/* Render a HTML table from a CSV file located in the assets/_data/semantic-core directory (Global resource). - CSV file should be a 2D array with the first array/row as the header. + CSV file should be a 2D array with the first array/row as the header. - Note: + Note: - csv files mounted from websites-sources: https://github.com/DataDog/websites-sources/tree/main/assets/_data/semantic-core - csv files cannot be mounted to the ./data directory (https://gohugo.io/content-management/data-sources/) @@ -11,24 +11,30 @@ {{ $resource_path := print "_data/semantic-core/" (.Get "resource")}} {{ $resource := resources.Get $resource_path}} +{{ $allowed_cols := slice "otel" "description" }} {{ if $resource }} +{{ $rows := unmarshal $resource }} +{{ $headers := index $rows 0 }}
- {{ range (index (unmarshal $resource) 0) }} - {{ $header := cond (eq . "dd") "Datadog" .}} - + {{ range $headers }} + {{ if in $allowed_cols . }} + + {{ end }} {{ end }} - {{ range $index, $row := (unmarshal $resource) }} + {{ range $index, $row := $rows }} {{ if $index }} - {{ range $row }} - + {{ range $i, $cell := $row }} + {{ if in $allowed_cols (index $headers $i) }} + + {{ end }} {{ end }} {{ end }} From 5d7a995c763a7a4960202abfb52c65259f7a5216 Mon Sep 17 00:00:00 2001 From: "stefon.simmons" Date: Tue, 5 May 2026 17:12:02 -0400 Subject: [PATCH 2/3] deduplicate rows based on OTel metric name and description. Only the specified columns are rendered, improving data clarity and preventing redundancy. --- layouts/shortcodes/mapping-table.html | 28 ++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/layouts/shortcodes/mapping-table.html b/layouts/shortcodes/mapping-table.html index 6946e6ba34d..56873eba303 100644 --- a/layouts/shortcodes/mapping-table.html +++ b/layouts/shortcodes/mapping-table.html @@ -11,6 +11,8 @@ {{ $resource_path := print "_data/semantic-core/" (.Get "resource")}} {{ $resource := resources.Get $resource_path}} + +{{/* Only render otel metric name and description */}} {{ $allowed_cols := slice "otel" "description" }} {{ if $resource }} @@ -28,15 +30,31 @@ + {{/* Get column indices of "otel" and "description" — both form the composite dedupe key */}} + {{ $otel_idx := 0 }} + {{ $desc_idx := 0 }} + {{ range $i, $h := $headers }} + {{ if eq $h "otel" }}{{ $otel_idx = $i }}{{ end }} + {{ if eq $h "description" }}{{ $desc_idx = $i }}{{ end }} + {{ end }} + + {{ $unique_vals := newScratch }} {{ range $index, $row := $rows }} {{ if $index }} - - {{ range $i, $cell := $row }} - {{ if in $allowed_cols (index $headers $i) }} - + {{/* Build a composite key from otel+description vals so rows with the same metric name + but different descriptions are treated as distinct */}} + {{ $dedupe_key := print (index $row $otel_idx) "|" (index $row $desc_idx) }} + {{/* Deduplicate: skips the row if $unique_vals already recorded this $dedupe_key */}} + {{ if not ($unique_vals.Get $dedupe_key) }} + {{ $unique_vals.Set $dedupe_key true }} + + {{ range $i, $cell := $row }} + {{ if in $allowed_cols (index $headers $i) }} + + {{ end }} {{ end }} + {{ end }} - {{ end }} {{ end }} From dde76e66e30cf26d6c92cd1c43a6d1ec6ed1dc99 Mon Sep 17 00:00:00 2001 From: "stefon.simmons" Date: Wed, 6 May 2026 14:46:18 -0400 Subject: [PATCH 3/3] add filter col --- layouts/shortcodes/mapping-table.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/layouts/shortcodes/mapping-table.html b/layouts/shortcodes/mapping-table.html index 56873eba303..6d6f98ce8d8 100644 --- a/layouts/shortcodes/mapping-table.html +++ b/layouts/shortcodes/mapping-table.html @@ -12,8 +12,8 @@ {{ $resource_path := print "_data/semantic-core/" (.Get "resource")}} {{ $resource := resources.Get $resource_path}} -{{/* Only render otel metric name and description */}} -{{ $allowed_cols := slice "otel" "description" }} +{{/* Only render these columns from the csv */}} +{{ $allowed_cols := slice "otel" "description" "filter"}} {{ if $resource }} {{ $rows := unmarshal $resource }} @@ -30,21 +30,21 @@ - {{/* Get column indices of "otel" and "description" — both form the composite dedupe key */}} + {{/* Get column indices of "otel" and "filter" to form the composite dedupe key */}} {{ $otel_idx := 0 }} - {{ $desc_idx := 0 }} + {{ $filter_idx := 0 }} {{ range $i, $h := $headers }} {{ if eq $h "otel" }}{{ $otel_idx = $i }}{{ end }} - {{ if eq $h "description" }}{{ $desc_idx = $i }}{{ end }} + {{ if eq $h "filter" }}{{ $filter_idx = $i }}{{ end }} {{ end }} {{ $unique_vals := newScratch }} {{ range $index, $row := $rows }} {{ if $index }} - {{/* Build a composite key from otel+description vals so rows with the same metric name - but different descriptions are treated as distinct */}} - {{ $dedupe_key := print (index $row $otel_idx) "|" (index $row $desc_idx) }} - {{/* Deduplicate: skips the row if $unique_vals already recorded this $dedupe_key */}} + {{/* Build a composite key from otel+filter vals so rows with the same metric name + but different filter are treated as distinct */}} + {{ $dedupe_key := print (index $row $otel_idx) "|" (index $row $filter_idx) }} + {{/* Deduplicate: skips the row if $unique_vals already recorded the $dedupe_key */}} {{ if not ($unique_vals.Get $dedupe_key) }} {{ $unique_vals.Set $dedupe_key true }}
{{ $header | upper }}{{ . | upper }}
{{ . | markdownify }}{{ $cell | markdownify }}
{{ $cell | markdownify }}
{{ $cell | markdownify }}