+ if _, ok := cache_allcountervects[vecid]; !ok {
+ Logger.Debug("Register new counter vector with opts: %v labelNames: %v", opts, labelNames)
+ entry := CounterVec{}
+ entry.Opts = opts
+ entry.Labels = labelNames
+ entry.Vec = promauto.NewCounterVec(prometheus.CounterOpts(entry.Opts), entry.Labels)
+ cache_allcountervects[vecid] = entry
+ }
+ entry := cache_allcountervects[vecid]
+ if strSliceCompare(entry.Labels, labelNames) == false {
+ Logger.Warn("id:%s cached counter vec labels dont match %v != %v", vecid, entry.Labels, labelNames)
+ return nil
+ }
+ valid := m.getFullName(prometheus.Opts(entry.Opts), labelValues)
+ if _, ok := cache_allcounters[valid]; !ok {
+ Logger.Debug("Register new counter from vector with opts: %v labelValues: %v", entry.Opts, labelValues)
+ cache_allcounters[valid] = entry.Vec.WithLabelValues(labelValues...)
+ }
+ return cache_allcounters[valid]
+}
+
+//
+//
+//
+func (m *Metrics) RegisterLabeledCounterGroup(optsgroup []CounterOpts, labelNames []string, labelValues []string, subsytem string) map[string]Counter {
+ c := make(map[string]Counter)
+ for _, opts := range optsgroup {
+ c[opts.Name] = m.RegisterLabeledCounter(opts, labelNames, labelValues, subsytem)
+ }
+ return c
+}
+
+//
+//
+//
+func (m *Metrics) RegisterGauge(opts CounterOpts, subsytem string) Gauge {
+ globalLock.Lock()
+ defer globalLock.Unlock()
+ opts.Namespace = m.Namespace
+ opts.Subsystem = subsytem
+ id := m.getFullName(prometheus.Opts(opts), []string{})
+ if _, ok := cache_allgaugevects[id]; ok {
+ Logger.Warn("Register new gauge with opts: %v, name conflicts existing gauge vector", opts)
+ return nil
+ }
+ if _, ok := cache_allgauges[id]; !ok {
+ Logger.Debug("Register new gauge with opts: %v", opts)
+ cache_allgauges[id] = promauto.NewGauge(prometheus.GaugeOpts(opts))
+ }
+ return cache_allgauges[id]