From e387b323f0a01617665709938210e93ebeeae107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Mon, 4 Nov 2024 11:35:44 +0100 Subject: [PATCH] refactor --- exporters/prometheus/exporter.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/exporters/prometheus/exporter.go b/exporters/prometheus/exporter.go index bec530a84aa..3cd457a03c3 100644 --- a/exporters/prometheus/exporter.go +++ b/exporters/prometheus/exporter.go @@ -356,13 +356,12 @@ func createInfoMetric(name, description string, res *resource.Resource) (prometh } func createScopeInfoMetric(scope instrumentation.Scope) (prometheus.Metric, error) { - attrs := []attribute.KeyValue{ - attribute.String("otel_scope_name", scope.Name), - attribute.String("otel_scope_version", scope.Version), - } + attrs := make([]attribute.KeyValue, 0, scope.Attributes.Len()+2) // resource attrs + scope name + scope version attrs = append(attrs, scope.Attributes.ToSlice()...) + attrs = append(attrs, attribute.String(scopeNameLabel, scope.Name)) + attrs = append(attrs, attribute.String(scopeVersionLabel, scope.Version)) - keys, values := getAttrs(attribute.NewSet(attrs...)) + keys, values := getAttrs(attribute.NewSet(attrs...)) desc := prometheus.NewDesc(scopeInfoMetricName, scopeInfoDescription, keys, nil) return prometheus.NewConstMetric(desc, prometheus.GaugeValue, float64(1), values...) }