Skip to content

Commit 5b8d569

Browse files
authored
[mdatagen] Add variable for metric name (#12531)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Add variable for metric name in mdatagen, accessing via `metadata.MetricsInfo.<metric-variable>.Name` <!-- Issue number if applicable --> #### Link to tracking issue Fixes #12459 <!--Describe what testing was performed and which tests were added.--> #### Testing n/a <!--Describe the documentation added.--> #### Documentation Added <!--Please delete paragraphs that you did not use before submitting.-->
1 parent 92ab7df commit 5b8d569

File tree

5 files changed

+133
-0
lines changed

5 files changed

+133
-0
lines changed
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: mdatagen
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add variable for metric name in mdatagen
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [12459]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: Access metric name via `metadata.MetricsInfo.<metric-variable>.Name`
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [api]

cmd/mdatagen/internal/sampleconnector/internal/metadata/generated_metrics.go

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/mdatagen/internal/samplereceiver/internal/metadata/generated_metrics.go

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/mdatagen/internal/samplescraper/internal/metadata/generated_metrics.go

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/mdatagen/internal/templates/metrics.go.tmpl

+18
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,24 @@ var MapAttribute{{ $name.Render }} = map[string]Attribute{{ $name.Render }}{
5656
{{ end }}
5757
{{- end }}
5858

59+
var MetricsInfo = metricsInfo{
60+
{{- range $name, $metric := .Metrics }}
61+
{{ $name.Render }}: metricInfo{
62+
Name: "{{ $name }}",
63+
},
64+
{{- end }}
65+
}
66+
67+
type metricsInfo struct {
68+
{{- range $name, $metric := .Metrics }}
69+
{{ $name.Render }} metricInfo
70+
{{- end }}
71+
}
72+
73+
type metricInfo struct {
74+
Name string
75+
}
76+
5977
{{ range $name, $metric := .Metrics -}}
6078
type metric{{ $name.Render }} struct {
6179
data pmetric.Metric // data buffer for generated metric.

0 commit comments

Comments
 (0)