Debian Codegraph @

cmd/mdatagen/internal/templates/documentation.md.tmpl

raw
1 {{- define "metric-documentation" -}}
2 {{- $metricName := . }}
3 {{- $metric := $metricName | metricInfo -}}
4
5 ### {{ $metricName }}
6
7 {{ $metric.Description }}
8
9 {{- if $metric.ExtendedDocumentation }}
10
11 {{ $metric.ExtendedDocumentation }}
12
13 {{- end }}
14
15 | Unit | Metric Type | Value Type |{{ if $metric.Data.HasAggregated }} Aggregation Temporality |{{ end }}{{ if $metric.Data.HasMonotonic }} Monotonic |{{ end }}{{ if $metric.Stability.Level }} Stability |{{ end }}{{ if $metric.SemanticConvention }} Semantic Convention |{{ end }}
16 | ---- | ----------- | ---------- |{{ if $metric.Data.HasAggregated }} ----------------------- |{{ end }}{{ if $metric.Data.HasMonotonic }} --------- |{{ end }}{{ if $metric.Stability.Level }} --------- |{{ end }}{{ if $metric.SemanticConvention }} ------------------- |{{ end }}
17 | {{ $metric.Unit }} | {{ $metric.Data.Type }} | {{ $metric.Data.MetricValueType }} |
18 {{- if $metric.Data.HasAggregated }} {{ $metric.Data.AggregationTemporality }} |{{ end }}
19 {{- if $metric.Data.HasMonotonic }} {{ $metric.Data.Monotonic }} |{{ end }}
20 {{- if $metric.Stability.Level }} {{ $metric.Stability.Level }} |{{ end }}
21 {{- if $metric.SemanticConvention }} [{{ $metricName }}]({{ $metric.SemanticConvention.SemanticConventionRef }}) |{{ end }}
22
23 {{- if $metric.Attributes }}
24
25 #### Attributes
26
27 | Name | Description | Values | Requirement Level |
28 | ---- | ----------- | ------ | -------- |
29 {{- range $metric.Attributes }}
30 {{- $attribute := . | attributeInfo }}
31 | {{ $attribute.Name }} | {{ $attribute.Description }} |
32 {{- if $attribute.Enum }} {{ $attribute.Type }}: ``{{ stringsJoin $attribute.Enum "``, ``" }}``{{ else }} Any {{ $attribute.Type }}{{ end }} | {{ $attribute.RequirementLevel }} |
33 {{- end }}
34
35 {{- end }}
36
37 {{- end -}}
38
39 {{- define "event-documentation" -}}
40 {{- $eventName := . }}
41 {{- $event := $eventName | eventInfo -}}
42
43 ### {{ $eventName }}
44
45 {{ $event.Description }}
46
47 {{- if $event.ExtendedDocumentation }}
48
49 {{ $event.ExtendedDocumentation }}
50
51 {{- end }}
52
53 {{- if $event.Attributes }}
54
55 #### Attributes
56
57 | Name | Description | Values |
58 | ---- | ----------- | ------ |
59 {{- range $event.Attributes }}
60 {{- $attribute := . | attributeInfo }}
61 | {{ $attribute.Name }} | {{ $attribute.Description }} |
62 {{- if $attribute.Enum }} {{ $attribute.Type }}: ``{{ stringsJoin $attribute.Enum "``, ``" }}``{{ else }} Any {{ $attribute.Type }}{{ end }} |
63 {{- end }}
64
65 {{- end }}
66
67 {{- end -}}
68
69 {{- define "telemetry-documentation" -}}
70 {{- $metricName := . }}
71 {{- $metric := $metricName | telemetryInfo -}}
72
73 ### {{ if $metric.Prefix -}}{{ $metric.Prefix }}{{- else -}}otelcol_{{- end -}}{{ $metricName }}
74
75 {{ $metric.Description }}{{ $metric.Stability }}
76
77 {{- if $metric.ExtendedDocumentation }}
78
79 {{ $metric.ExtendedDocumentation }}
80
81 {{- end }}
82
83 | Unit | Metric Type | Value Type |{{ if $metric.Data.HasMonotonic }} Monotonic |{{ end }}{{ if $metric.Stability.Level }} Stability |{{ end }}{{ if $metric.SemanticConvention }} Semantic Convention |{{ end }}
84 | ---- | ----------- | ---------- |{{ if $metric.Data.HasMonotonic }} --------- |{{ end }}{{ if $metric.Stability.Level }} --------- |{{ end }}{{ if $metric.SemanticConvention }} ------------------- |{{ end }}
85 | {{ $metric.Unit }} | {{ $metric.Data.Type }} | {{ $metric.Data.MetricValueType }} |
86 {{- if $metric.Data.HasMonotonic }} {{ $metric.Data.Monotonic }} |{{ end }}
87 {{- if $metric.Stability.Level }} {{ $metric.Stability.Level }} |{{ end }}
88 {{- if $metric.SemanticConvention }} [{{ $metricName }}]({{ $metric.SemanticConvention.SemanticConventionRef }}) |{{ end }}
89
90 {{- if $metric.Attributes }}
91
92 #### Attributes
93
94 | Name | Description | Values |
95 | ---- | ----------- | ------ |
96 {{- range $metric.Attributes }}
97 {{- $attribute := . | attributeInfo }}
98 | {{ $attribute.Name }} | {{ $attribute.Description }} |
99 {{- if $attribute.Enum }} {{ $attribute.Type }}: ``{{ stringsJoin $attribute.Enum "``, ``" }}``{{ else }} Any {{ $attribute.Type }}{{ end }} |
100 {{- end }}
101
102 {{- end }}
103
104 {{- end -}}
105
106 [comment]: <> (Code generated by mdatagen. DO NOT EDIT.)
107
108 # {{ .Type }}
109
110 {{- if .Parent }}
111
112 **Parent Component:** {{ .Parent }}
113 {{- end }}
114
115 {{- if .Metrics }}
116
117 ## Default Metrics
118
119 The following metrics are emitted by default. Each of them can be disabled by applying the following configuration:
120
121 ```yaml
122 metrics:
123 <metric_name>:
124 enabled: false
125 ```
126
127 {{- end }}
128
129 {{- range $metricName, $metric := .Metrics }}
130 {{- if $metric.Enabled }}
131
132 {{ template "metric-documentation" $metricName }}
133
134 {{- end }}
135 {{- end }}
136
137 {{- $optionalMetricSeen := false }}
138 {{- range $metricName, $metric := .Metrics }}
139 {{- if not $metric.Enabled }}
140 {{- if not $optionalMetricSeen }}
141
142 ## Optional Metrics
143
144 The following metrics are not emitted by default. Each of them can be enabled by applying the following configuration:
145
146 ```yaml
147 metrics:
148 <metric_name>:
149 enabled: true
150 ```
151
152 {{- end }}
153 {{- $optionalMetricSeen = true }}
154
155 {{ template "metric-documentation" $metricName }}
156
157 {{- end }}
158 {{- end }}
159
160 {{- if .Events }}
161
162 ## Default Events
163
164 The following events are emitted by default. Each of them can be disabled by applying the following configuration:
165
166 ```yaml
167 events:
168 <event_name>:
169 enabled: false
170 ```
171
172 {{- range $eventName, $event := .Events }}
173 {{- if $event.Enabled }}
174
175 {{ template "event-documentation" $eventName }}
176
177 {{- end }}
178 {{- end }}
179 {{- end }}
180
181 {{- $optionalEventSeen := false }}
182 {{- range $eventName, $event := .Events }}
183 {{- if not $event.Enabled }}
184 {{- if not $optionalEventSeen }}
185
186 ## Optional Events
187
188 The following events are not emitted by default. Each of them can be enabled by applying the following configuration:
189
190 ```yaml
191 events:
192 <event_name>:
193 enabled: true
194 ```
195
196 {{- end }}
197 {{- $optionalEventSeen = true }}
198
199 {{ template "event-documentation" $eventName }}
200
201 {{- end }}
202 {{- end }}
203
204 {{- if .ResourceAttributes }}
205
206 ## Resource Attributes
207
208 | Name | Description | Values | Enabled |
209 | ---- | ----------- | ------ | ------- |
210 {{- range $attributeName, $attribute := .ResourceAttributes }}
211 | {{ $attributeName }} | {{ $attribute.Description }} |
212 {{- if $attribute.Enum }} {{ $attribute.Type }}: ``{{ stringsJoin $attribute.Enum "``, ``" }}``{{ else }} Any {{ $attribute.Type }}{{ end }} | {{ $attribute.Enabled }} |
213 {{- end }}
214
215 {{- end }}
216
217 {{- if .Entities }}
218
219 ## Entities
220
221 The following entities are defined for this component:
222
223 {{- range $entity := .Entities }}
224
225 ### {{ $entity.Type }}
226
227 {{ $entity.Brief }}
228
229 {{- if $entity.Stability }}
230
231 **Stability:** {{ $entity.Stability }}
232 {{- end }}
233
234 {{- if $entity.Identity }}
235
236 **Identity Attributes:**
237 {{- range $entity.Identity }}
238 - `{{ .Ref }}`
239 {{- end }}
240 {{- end }}
241
242 {{- if $entity.Description }}
243
244 **Description Attributes:**
245 {{- range $entity.Description }}
246 - `{{ .Ref }}`
247 {{- end }}
248 {{- end }}
249
250 {{- end }}
251
252 {{- end }}
253
254 {{- if .Telemetry.Metrics }}
255
256 ## Internal Telemetry
257
258 The following telemetry is emitted by this component.
259
260 {{- range $metricName, $metric := .Telemetry.Metrics }}
261 {{- if $metric.Enabled }}
262
263 {{ template "telemetry-documentation" $metricName }}
264
265 {{- end }}
266 {{- end }}
267
268 {{- end }}