Removed deprecaded code
[ric-plt/xapp-frame.git] / pkg / xapp / metrics.go
index ef5ba30..8e13f7c 100644 (file)
@@ -21,11 +21,12 @@ package xapp
 
 import (
        "fmt"
+       "sync"
+
        "github.com/gorilla/mux"
        "github.com/prometheus/client_golang/prometheus"
        "github.com/prometheus/client_golang/prometheus/promauto"
        "github.com/prometheus/client_golang/prometheus/promhttp"
-       "sync"
 )
 
 //-----------------------------------------------------------------------------
@@ -474,204 +475,3 @@ func (m *Metrics) RegisterLabeledGaugeGroup(optsgroup []CounterOpts, labelNames
        }
        return c
 }
-
-/*
- * Handling counter vectors
- *
- * Examples:
-
-  //---------
-       vec := Metric.RegisterCounterVec(
-               CounterOpts{Name: "counter0", Help: "counter0"},
-               []string{"host"},
-               "SUBSYSTEM")
-
-       stat:=Metric.GetCounterFromVect([]string{"localhost:8888"},vec)
-       stat.Inc()
-
-  //---------
-       vec := Metric.RegisterCounterVecGroup(
-               []CounterOpts{
-                       {Name: "counter1", Help: "counter1"},
-                       {Name: "counter2", Help: "counter2"},
-               },
-               []string{"host"},
-               "SUBSYSTEM")
-
-       stats:=Metric.GetCounterGroupFromVects([]string{"localhost:8888"}, vec)
-       stats["counter1"].Inc()
-*/
-
-// Deprecated: Use RegisterLabeledCounter
-func (m *Metrics) RegisterCounterVec(opts CounterOpts, labelNames []string, subsytem string) CounterVec {
-       globalLock.Lock()
-       defer globalLock.Unlock()
-       opts.Namespace = m.Namespace
-       opts.Subsystem = subsytem
-       vecid := m.getFullName(prometheus.Opts(opts), []string{})
-       if _, ok := cache_allcounters[vecid]; ok {
-               Logger.Warn("Register new counter vector with opts: %v labelNames: %v, name conflicts existing counter", opts, labelNames)
-               return CounterVec{}
-       }
-       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 CounterVec{}
-       }
-       return entry
-}
-
-// Deprecated: Use RegisterLabeledCounterGroup
-func (m *Metrics) RegisterCounterVecGroup(optsgroup []CounterOpts, labelNames []string, subsytem string) map[string]CounterVec {
-       c := make(map[string]CounterVec)
-       for _, opts := range optsgroup {
-               ret := m.RegisterCounterVec(opts, labelNames, subsytem)
-               if ret.Vec != nil {
-                       c[opts.Name] = ret
-               }
-       }
-       return c
-}
-
-// Deprecated: Use RegisterLabeledCounter
-func (m *Metrics) GetCounterFromVect(labelValues []string, vec CounterVec) (c Counter) {
-       globalLock.Lock()
-       defer globalLock.Unlock()
-       valid := m.getFullName(prometheus.Opts(vec.Opts), labelValues)
-       if _, ok := cache_allcounters[valid]; !ok {
-               Logger.Debug("Register new counter from vector with opts: %v labelValues: %v", vec.Opts, labelValues)
-               cache_allcounters[valid] = vec.Vec.WithLabelValues(labelValues...)
-       }
-       return cache_allcounters[valid]
-}
-
-// Deprecated: Use RegisterLabeledCounterGroup
-func (m *Metrics) GetCounterGroupFromVects(labelValues []string, vects ...map[string]CounterVec) map[string]Counter {
-       c := make(map[string]Counter)
-       for _, vect := range vects {
-               for name, vec := range vect {
-                       c[name] = m.GetCounterFromVect(labelValues, vec)
-               }
-       }
-       return c
-}
-
-// Deprecated: Use RegisterLabeledCounterGroup
-func (m *Metrics) GetCounterGroupFromVectsWithPrefix(prefix string, labelValues []string, vects ...map[string]CounterVec) map[string]Counter {
-       c := make(map[string]Counter)
-       for _, vect := range vects {
-               for name, vec := range vect {
-                       c[prefix+name] = m.GetCounterFromVect(labelValues, vec)
-               }
-       }
-       return c
-}
-
-/*
- * Handling gauge vectors
- *
- * Examples:
-
-  //---------
-       vec := Metric.RegisterGaugeVec(
-               CounterOpts{Name: "gauge0", Help: "gauge0"},
-               []string{"host"},
-               "SUBSYSTEM")
-
-       stat:=Metric.GetGaugeFromVect([]string{"localhost:8888"},vec)
-       stat.Inc()
-
-  //---------
-       vecgrp := Metric.RegisterGaugeVecGroup(
-               []CounterOpts{
-                       {Name: "gauge1", Help: "gauge1"},
-                       {Name: "gauge2", Help: "gauge2"},
-               },
-               []string{"host"},
-               "SUBSYSTEM")
-
-       stats:=Metric.GetGaugeGroupFromVects([]string{"localhost:8888"},vecgrp)
-       stats["gauge1"].Inc()
-*/
-
-// Deprecated: Use RegisterLabeledGauge
-func (m *Metrics) RegisterGaugeVec(opts CounterOpts, labelNames []string, subsytem string) GaugeVec {
-       globalLock.Lock()
-       defer globalLock.Unlock()
-       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 GaugeVec{}
-       }
-       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 GaugeVec{}
-       }
-       return entry
-}
-
-// Deprecated: Use RegisterLabeledGaugeGroup
-func (m *Metrics) RegisterGaugeVecGroup(optsgroup []CounterOpts, labelNames []string, subsytem string) map[string]GaugeVec {
-       c := make(map[string]GaugeVec)
-       for _, opts := range optsgroup {
-               ret := m.RegisterGaugeVec(opts, labelNames, subsytem)
-               if ret.Vec != nil {
-                       c[opts.Name] = ret
-               }
-
-       }
-       return c
-}
-
-// Deprecated: Use RegisterLabeledGauge
-func (m *Metrics) GetGaugeFromVect(labelValues []string, vec GaugeVec) Gauge {
-       globalLock.Lock()
-       defer globalLock.Unlock()
-       valid := m.getFullName(prometheus.Opts(vec.Opts), labelValues)
-       if _, ok := cache_allgauges[valid]; !ok {
-               Logger.Debug("Register new gauge from vector with opts: %v labelValues: %v", vec.Opts, labelValues)
-               cache_allgauges[valid] = vec.Vec.WithLabelValues(labelValues...)
-       }
-       return cache_allgauges[valid]
-}
-
-// Deprecated: Use RegisterLabeledGaugeGroup
-func (m *Metrics) GetGaugeGroupFromVects(labelValues []string, vects ...map[string]GaugeVec) map[string]Gauge {
-       c := make(map[string]Gauge)
-       for _, vect := range vects {
-               for name, vec := range vect {
-                       c[name] = m.GetGaugeFromVect(labelValues, vec)
-               }
-       }
-       return c
-}
-
-// Deprecated: Use RegisterLabeledGaugeGroup
-func (m *Metrics) GetGaugeGroupFromVectsWithPrefix(prefix string, labelValues []string, vects ...map[string]GaugeVec) map[string]Gauge {
-       c := make(map[string]Gauge)
-       for _, vect := range vects {
-               for name, vec := range vect {
-                       c[prefix+name] = m.GetGaugeFromVect(labelValues, vec)
-               }
-       }
-       return c
-}