forked from TrueCloudLab/frostfs-node
[#395] metrics: Drop redundant metrics
HistogramVec already has labeled counter. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
bc34fee6a7
commit
271a56c2ab
2 changed files with 16 additions and 63 deletions
|
@ -63,21 +63,18 @@ type writeCacheMetrics struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) Get(d time.Duration, success bool, st writecache.StorageType) {
|
func (m *writeCacheMetrics) Get(d time.Duration, success bool, st writecache.StorageType) {
|
||||||
m.metrics.AddGetDuration(m.shardID, success, d)
|
m.metrics.AddGetDuration(m.shardID, success, d, st.String())
|
||||||
m.metrics.IncGetCounter(m.shardID, success, st.String())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) Delete(d time.Duration, success bool, st writecache.StorageType) {
|
func (m *writeCacheMetrics) Delete(d time.Duration, success bool, st writecache.StorageType) {
|
||||||
m.metrics.AddDeleteDuration(m.shardID, success, d)
|
m.metrics.AddDeleteDuration(m.shardID, success, d, st.String())
|
||||||
m.metrics.IncDeleteCounter(m.shardID, success, st.String())
|
|
||||||
if success {
|
if success {
|
||||||
m.metrics.DecActualCount(m.shardID, st.String())
|
m.metrics.DecActualCount(m.shardID, st.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) Put(d time.Duration, success bool, st writecache.StorageType) {
|
func (m *writeCacheMetrics) Put(d time.Duration, success bool, st writecache.StorageType) {
|
||||||
m.metrics.AddPutDuration(m.shardID, success, d)
|
m.metrics.AddPutDuration(m.shardID, success, d, st.String())
|
||||||
m.metrics.IncPutCounter(m.shardID, success, st.String())
|
|
||||||
if success {
|
if success {
|
||||||
m.metrics.IncActualCount(m.shardID, st.String())
|
m.metrics.IncActualCount(m.shardID, st.String())
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,14 +21,9 @@ type shardIDMode struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type WriteCacheMetrics interface {
|
type WriteCacheMetrics interface {
|
||||||
AddGetDuration(shardID string, success bool, d time.Duration)
|
AddGetDuration(shardID string, success bool, d time.Duration, storageType string)
|
||||||
IncGetCounter(shardID string, success bool, storageType string)
|
AddDeleteDuration(shardID string, success bool, d time.Duration, storageType string)
|
||||||
|
AddPutDuration(shardID string, success bool, d time.Duration, storageType string)
|
||||||
AddDeleteDuration(shardID string, success bool, d time.Duration)
|
|
||||||
IncDeleteCounter(shardID string, success bool, storageType string)
|
|
||||||
|
|
||||||
AddPutDuration(shardID string, success bool, d time.Duration)
|
|
||||||
IncPutCounter(shardID string, success bool, storageType string)
|
|
||||||
|
|
||||||
IncActualCount(shardID string, storageType string)
|
IncActualCount(shardID string, storageType string)
|
||||||
DecActualCount(shardID string, storageType string)
|
DecActualCount(shardID string, storageType string)
|
||||||
|
@ -43,13 +38,8 @@ type WriteCacheMetrics interface {
|
||||||
|
|
||||||
type writeCacheMetrics struct {
|
type writeCacheMetrics struct {
|
||||||
getDuration metric[*prometheus.HistogramVec]
|
getDuration metric[*prometheus.HistogramVec]
|
||||||
getCounter metric[*prometheus.CounterVec]
|
|
||||||
|
|
||||||
putDuration metric[*prometheus.HistogramVec]
|
putDuration metric[*prometheus.HistogramVec]
|
||||||
putCounter metric[*prometheus.CounterVec]
|
|
||||||
|
|
||||||
deleteDuration metric[*prometheus.HistogramVec]
|
deleteDuration metric[*prometheus.HistogramVec]
|
||||||
deleteCounter metric[*prometheus.CounterVec]
|
|
||||||
|
|
||||||
flushCounter metric[*prometheus.CounterVec]
|
flushCounter metric[*prometheus.CounterVec]
|
||||||
evictCounter metric[*prometheus.CounterVec]
|
evictCounter metric[*prometheus.CounterVec]
|
||||||
|
@ -66,11 +56,8 @@ type writeCacheMetrics struct {
|
||||||
func newWriteCacheMetrics() *writeCacheMetrics {
|
func newWriteCacheMetrics() *writeCacheMetrics {
|
||||||
return &writeCacheMetrics{
|
return &writeCacheMetrics{
|
||||||
getDuration: newWCMethodDurationCounter("get"),
|
getDuration: newWCMethodDurationCounter("get"),
|
||||||
getCounter: newWCMethodCounterVec("get"),
|
|
||||||
putDuration: newWCMethodDurationCounter("put"),
|
putDuration: newWCMethodDurationCounter("put"),
|
||||||
putCounter: newWCMethodCounterVec("put"),
|
|
||||||
deleteDuration: newWCMethodDurationCounter("delete"),
|
deleteDuration: newWCMethodDurationCounter("delete"),
|
||||||
deleteCounter: newWCMethodCounterVec("delete"),
|
|
||||||
flushCounter: newWCOperationCounterVec("flush", []string{wcShardID, wcStorage, wcSuccess}),
|
flushCounter: newWCOperationCounterVec("flush", []string{wcShardID, wcStorage, wcSuccess}),
|
||||||
evictCounter: newWCOperationCounterVec("evict", []string{wcShardID, wcStorage}),
|
evictCounter: newWCOperationCounterVec("evict", []string{wcShardID, wcStorage}),
|
||||||
actualCount: newWCGaugeVec("actual_objects_count", "Actual objects count in writecache", []string{wcShardID, wcStorage}),
|
actualCount: newWCGaugeVec("actual_objects_count", "Actual objects count in writecache", []string{wcShardID, wcStorage}),
|
||||||
|
@ -81,28 +68,16 @@ func newWriteCacheMetrics() *writeCacheMetrics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) AddGetDuration(shardID string, success bool, d time.Duration) {
|
func (m *writeCacheMetrics) AddGetDuration(shardID string, success bool, d time.Duration, storageType string) {
|
||||||
setWriteCacheDuration(m.getDuration.value, shardID, success, d)
|
setWriteCacheDuration(m.getDuration.value, shardID, success, d, storageType)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) IncGetCounter(shardID string, success bool, storageType string) {
|
func (m *writeCacheMetrics) AddDeleteDuration(shardID string, success bool, d time.Duration, storageType string) {
|
||||||
incWriteCacheCounter(m.getCounter.value, shardID, success, storageType)
|
setWriteCacheDuration(m.deleteDuration.value, shardID, success, d, storageType)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) AddDeleteDuration(shardID string, success bool, d time.Duration) {
|
func (m *writeCacheMetrics) AddPutDuration(shardID string, success bool, d time.Duration, storageType string) {
|
||||||
setWriteCacheDuration(m.deleteDuration.value, shardID, success, d)
|
setWriteCacheDuration(m.putDuration.value, shardID, success, d, storageType)
|
||||||
}
|
|
||||||
|
|
||||||
func (m *writeCacheMetrics) IncDeleteCounter(shardID string, success bool, storageType string) {
|
|
||||||
incWriteCacheCounter(m.deleteCounter.value, shardID, success, storageType)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *writeCacheMetrics) AddPutDuration(shardID string, success bool, d time.Duration) {
|
|
||||||
setWriteCacheDuration(m.putDuration.value, shardID, success, d)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *writeCacheMetrics) IncPutCounter(shardID string, success bool, storageType string) {
|
|
||||||
incWriteCacheCounter(m.putCounter.value, shardID, success, storageType)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) IncActualCount(shardID string, storageType string) {
|
func (m *writeCacheMetrics) IncActualCount(shardID string, storageType string) {
|
||||||
|
@ -187,49 +162,30 @@ func (m *writeCacheMetrics) IncEvictCounter(shardID string, storageType string)
|
||||||
|
|
||||||
func (m *writeCacheMetrics) register() {
|
func (m *writeCacheMetrics) register() {
|
||||||
mustRegister(m.getDuration)
|
mustRegister(m.getDuration)
|
||||||
mustRegister(m.getCounter)
|
|
||||||
mustRegister(m.putDuration)
|
mustRegister(m.putDuration)
|
||||||
mustRegister(m.putCounter)
|
|
||||||
mustRegister(m.deleteDuration)
|
mustRegister(m.deleteDuration)
|
||||||
mustRegister(m.deleteCounter)
|
|
||||||
mustRegister(m.actualCount)
|
mustRegister(m.actualCount)
|
||||||
mustRegister(m.estimatedSize)
|
mustRegister(m.estimatedSize)
|
||||||
mustRegister(m.flushCounter)
|
mustRegister(m.flushCounter)
|
||||||
mustRegister(m.evictCounter)
|
mustRegister(m.evictCounter)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setWriteCacheDuration(m *prometheus.HistogramVec, shardID string, success bool, d time.Duration) {
|
func setWriteCacheDuration(m *prometheus.HistogramVec, shardID string, success bool, d time.Duration, storageType string) {
|
||||||
m.With(
|
m.With(
|
||||||
prometheus.Labels{
|
prometheus.Labels{
|
||||||
wcShardID: shardID,
|
wcShardID: shardID,
|
||||||
wcSuccess: fmt.Sprintf("%v", success),
|
wcSuccess: fmt.Sprintf("%v", success),
|
||||||
|
wcStorage: storageType,
|
||||||
},
|
},
|
||||||
).Observe(float64(d))
|
).Observe(float64(d))
|
||||||
}
|
}
|
||||||
|
|
||||||
func incWriteCacheCounter(m *prometheus.CounterVec, shardID string, success bool, storageType string) {
|
|
||||||
m.With(prometheus.Labels{
|
|
||||||
wcShardID: shardID,
|
|
||||||
wcSuccess: fmt.Sprintf("%v", success),
|
|
||||||
wcStorage: storageType,
|
|
||||||
}).Inc()
|
|
||||||
}
|
|
||||||
|
|
||||||
func newWCMethodDurationCounter(method string) metric[*prometheus.HistogramVec] {
|
func newWCMethodDurationCounter(method string) metric[*prometheus.HistogramVec] {
|
||||||
return newHistogramVec(prometheus.HistogramOpts{
|
return newHistogramVec(prometheus.HistogramOpts{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Subsystem: wcSubsystem,
|
Subsystem: wcSubsystem,
|
||||||
Name: fmt.Sprintf("%s_req_duration_seconds", method),
|
Name: fmt.Sprintf("%s_req_duration_seconds", method),
|
||||||
Help: fmt.Sprintf("Accumulated %s request process duration", method),
|
Help: fmt.Sprintf("Accumulated %s request process duration", method),
|
||||||
}, []string{wcShardID, wcSuccess})
|
|
||||||
}
|
|
||||||
|
|
||||||
func newWCMethodCounterVec(method string) metric[*prometheus.CounterVec] {
|
|
||||||
return newCounterVec(prometheus.CounterOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: wcSubsystem,
|
|
||||||
Name: fmt.Sprintf("%s_req_count", method),
|
|
||||||
Help: fmt.Sprintf("The number of %s requests processed", method),
|
|
||||||
}, []string{wcShardID, wcSuccess, wcStorage})
|
}, []string{wcShardID, wcSuccess, wcStorage})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue