- c = make(map[string]Gauge)
- for _, vec := range vects {
- for name, opt := range vec {
-
- id := m.getFullName(prometheus.Opts(opt.Opts), labels)
- if _, ok := cache_allgauges[id]; !ok {
- Logger.Info("Register new gauge from vector with opts: %v labels: %v prefix: %s", opt.Opts, labels, prefix)
- cache_allgauges[id] = opt.Vec.WithLabelValues(labels...)
- }
- c[prefix+name] = cache_allgauges[id]
- }
+ opts.Namespace = m.Namespace
+ opts.Subsystem = subsytem
+ vecid := m.getFullName(prometheus.Opts(opts), []string{})
+ if _, ok := cache_allgauges[vecid]; ok {
+ Logger.Warn("Register new gauge vector with opts: %v labelNames: %v, name conflicts existing counter", opts, labelNames)
+ return nil
+ }
+ if _, ok := cache_allgaugevects[vecid]; !ok {
+ Logger.Debug("Register new gauge vector with opts: %v labelNames: %v", opts, labelNames)
+ entry := GaugeVec{}
+ entry.Opts = opts
+ entry.Labels = labelNames
+ entry.Vec = promauto.NewGaugeVec(prometheus.GaugeOpts(entry.Opts), entry.Labels)
+ cache_allgaugevects[vecid] = entry
+ }
+ entry := cache_allgaugevects[vecid]
+ if strSliceCompare(entry.Labels, labelNames) == false {
+ Logger.Warn("id:%s cached gauge vec labels dont match %v != %v", vecid, entry.Labels, labelNames)
+ return nil