diff --git a/prometheus/promsafe/safe.go b/prometheus/promsafe/safe.go index 5cf7b9791..25e9ee899 100644 --- a/prometheus/promsafe/safe.go +++ b/prometheus/promsafe/safe.go @@ -117,7 +117,7 @@ func (h handler[T]) extractLabelsWithValues(labelProvider T) prometheus.Labels { // extractLabelValues extracts label string values from a given labelProviderMarker (SingleLabelProvider or StructLabelProvider) func (h handler[T]) extractLabelValues(labelProvider T) []string { - m := h.extractLabels(labelProvider) + m := h.extractLabelsWithValues(labelProvider) labelValues := make([]string, 0, len(m)) for _, v := range m { diff --git a/prometheus/promsafe/safe_test.go b/prometheus/promsafe/safe_test.go index ac0a7df38..6517b66fc 100644 --- a/prometheus/promsafe/safe_test.go +++ b/prometheus/promsafe/safe_test.go @@ -55,18 +55,17 @@ func ExampleNewCounterVecT_multiple_labels_manual() { } func ExampleNewCounterVecT_promauto_migrated() { - // Examples on how to migrate from promauto to promsafe // When promauto was using a custom factory with custom registry - var myReg = prometheus.NewRegistry() + myReg := prometheus.NewRegistry() counterOpts := prometheus.CounterOpts{ Name: "items_counted_detailed_auto", } // Old unsafe code - //promauto.With(myReg).NewCounterVec(counterOpts, []string{"event_type", "source"}) + // promauto.With(myReg).NewCounterVec(counterOpts, []string{"event_type", "source"}) // becomes: type TicketReservationAttemptsLabels struct {