Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared committed Nov 4, 2024
1 parent 8871b0f commit e387b32
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions exporters/prometheus/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}
Expand Down

0 comments on commit e387b32

Please sign in to comment.