MCPcopy
hub / github.com/prometheus/client_golang / isLabelCurried

Function isLabelCurried

prometheus/promhttp/instrument_server.go:372–390  ·  view source on GitHub ↗
(c prometheus.Collector, label string)

Source from the content-addressed store, hash-verified

370}
371
372func isLabelCurried(c prometheus.Collector, label string) bool {
373 // This is even hackier than the label test above.
374 // We essentially try to curry again and see if it works.
375 // But for that, we need to type-convert to the two
376 // types we use here, ObserverVec or *CounterVec.
377 switch v := c.(type) {
378 case *prometheus.CounterVec:
379 if _, err := v.CurryWith(prometheus.Labels{label: "dummy"}); err == nil {
380 return false
381 }
382 case prometheus.ObserverVec:
383 if _, err := v.CurryWith(prometheus.Labels{label: "dummy"}); err == nil {
384 return false
385 }
386 default:
387 panic("unsupported metric vec type")
388 }
389 return true
390}
391
392func labels(code, method bool, reqMethod string, status int, extraMethods ...string) prometheus.Labels {
393 labels := prometheus.Labels{}

Callers 1

checkLabelsFunction · 0.85

Calls 1

CurryWithMethod · 0.65

Tested by

no test coverage detected