Skip to content

Commit

Permalink
hotfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
amberpixels committed Aug 28, 2024
1 parent 80a733d commit c9c4dd4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion prometheus/promsafe/safe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions prometheus/promsafe/safe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c9c4dd4

Please sign in to comment.