"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
+ "sync"
)
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
type Metrics struct {
+ lock sync.Mutex
Namespace string
MetricGroupsCacheMap map[string]*MetricGroupsCache
}
*
*/
func (m *Metrics) GroupCacheGet(id string) *MetricGroupsCache {
+ m.lock.Lock()
+ defer m.lock.Unlock()
entry, ok := m.MetricGroupsCacheMap[id]
if ok == false {
return nil
}
func (m *Metrics) GroupCacheAddCounters(id string, vals map[string]Counter) {
+ m.lock.Lock()
+ defer m.lock.Unlock()
entry, ok := m.MetricGroupsCacheMap[id]
if ok == false {
entry = &MetricGroupsCache{}
}
func (m *Metrics) GroupCacheAddGauges(id string, vals map[string]Gauge) {
+ m.lock.Lock()
+ defer m.lock.Unlock()
entry, ok := m.MetricGroupsCacheMap[id]
if ok == false {
entry = &MetricGroupsCache{}
}
func (m *RMRClient) LogMBufError(text string, mbuf *C.rmr_mbuf_t) int {
- Logger.Debug(fmt.Sprintf("rmrClient: %s -> [tp=%v] %v - %s", text, mbuf.tp_state, mbuf.state, RMRErrors[int(mbuf.state)]))
- return int(mbuf.state)
+ if mbuf != nil {
+ Logger.Debug(fmt.Sprintf("rmrClient: %s -> [tp=%v] %v - %s", text, mbuf.tp_state, mbuf.state, RMRErrors[int(mbuf.state)]))
+ return int(mbuf.state)
+ }
+ Logger.Debug(fmt.Sprintf("rmrClient: %s -> mbuf nil", text))
+ return 0
}
// To be removed ...