diff --git a/scripts/metricsgen/metricsgen.go b/scripts/metricsgen/metricsgen.go index 70cb36a77..1dad927c0 100644 --- a/scripts/metricsgen/metricsgen.go +++ b/scripts/metricsgen/metricsgen.go @@ -251,8 +251,11 @@ func findMetricsStruct(files map[string]*ast.File, structName string) (*ast.Stru func parseMetricField(f *ast.Field) ParsedMetricField { var comment string if f.Doc != nil { - for _, c := range f.Doc.List { + for i, c := range f.Doc.List { comment += strings.TrimPrefix(c.Text, "// ") + if i < len(f.Doc.List)-1 { + comment += " " + } } } pmf := ParsedMetricField{ diff --git a/scripts/metricsgen/testdata/commented/metrics.gen.go b/scripts/metricsgen/testdata/commented/metrics.gen.go index 038da3d46..c1346da38 100644 --- a/scripts/metricsgen/testdata/commented/metrics.gen.go +++ b/scripts/metricsgen/testdata/commented/metrics.gen.go @@ -18,7 +18,7 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { Namespace: namespace, Subsystem: MetricsSubsystem, Name: "field", - Help: "Height of the chain.We expect multi-line comments to parse correctly.", + Help: "Height of the chain. We expect multi-line comments to parse correctly.", }, labels).With(labelsAndValues...), } }