Skip to content

Commit 1688d15

Browse files
authored
[docseng-32] read synthetics metadata (#30422)
* render synthetics Signed-off-by: Brian Deutsch <[email protected]> * update to include cloud foundry Signed-off-by: Brian Deutsch <[email protected]> --------- Signed-off-by: Brian Deutsch <[email protected]>
1 parent 2478a7c commit 1688d15

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

layouts/shortcodes/get-metrics-from-git.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,44 @@
11
{{- $int_name := (.Get 0 ) -}}
2+
{{- $metric_namespaces := (.Get 1 ) -}}
3+
{{- if and $metric_namespaces (not (reflect.IsSlice $metric_namespaces)) -}}
4+
{{- $metric_namespaces = slice $metric_namespaces -}}
5+
{{- end -}}
6+
27
{{- if $int_name -}}
8+
<!-- Some edge cases the metadata is from a non-integration source, we get the JSON from websites-sources -->
9+
<!-- The datafile in sources needs to follow the convention to match: appid_metadata.json -->
10+
{{- $exceptions := slice "synthetics" "cloud-foundry" -}}
11+
{{- if in $exceptions $int_name -}}
12+
{{- $data := index .Site.Data (print $int_name "_metadata") -}}
13+
{{- if $data -}}
14+
<table>
15+
{{- range $data -}}
16+
{{- $metric := . -}}
17+
{{- $shouldRender := false -}}
18+
{{- if not $metric_namespaces -}}
19+
{{- $shouldRender = true -}}
20+
{{- else -}}
21+
{{- range $metric_namespaces -}}
22+
{{- if hasPrefix $metric.metric_name . -}}
23+
{{- $shouldRender = true -}}
24+
{{- end -}}
25+
{{- end -}}
26+
{{- end -}}
27+
28+
{{- if $shouldRender -}}
29+
<tr>
30+
<td><strong>{{ .metric_name }}</strong> <br>({{ .metric_type }})</td>
31+
<td>{{ .description }} {{ with .unit_name }}<br><em>Shown as {{ . }}{{ end }}</em></td>
32+
</tr>
33+
{{- end -}}
34+
{{- end -}}
35+
</table>
36+
{{- else -}}
37+
{{ warnf "%s_metadata.json datafile not found for %s integration." $int_name $int_name }}
38+
{{- end -}}
39+
{{- else -}}
40+
41+
<!-- For integrations we get the metrics from the integration page -->
342
<!-- if the page is a draft we can skip -->
443
{{- if not .Page.Draft -}}
544
<!-- if non english page load from english integration -->
@@ -25,4 +64,5 @@
2564
{{- end -}}
2665
{{- end -}}
2766
{{- end -}}
67+
{{- end -}}
2868
{{- end -}}

0 commit comments

Comments
 (0)