forked from TrueCloudLab/frostfs-node
[#164] metrics: Allow to export metrics description
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
4ade5339da
commit
6fef2726b8
9 changed files with 229 additions and 91 deletions
|
@ -12,8 +12,8 @@ const objectSubsystem = "object"
|
|||
|
||||
type (
|
||||
methodCount struct {
|
||||
success prometheus.Counter
|
||||
total prometheus.Counter
|
||||
success metric[prometheus.Counter]
|
||||
total metric[prometheus.Counter]
|
||||
}
|
||||
|
||||
objectServiceMetrics struct {
|
||||
|
@ -25,19 +25,19 @@ type (
|
|||
rangeCounter methodCount
|
||||
rangeHashCounter methodCount
|
||||
|
||||
getDuration prometheus.Counter
|
||||
putDuration prometheus.Counter
|
||||
headDuration prometheus.Counter
|
||||
searchDuration prometheus.Counter
|
||||
deleteDuration prometheus.Counter
|
||||
rangeDuration prometheus.Counter
|
||||
rangeHashDuration prometheus.Counter
|
||||
getDuration metric[prometheus.Counter]
|
||||
putDuration metric[prometheus.Counter]
|
||||
headDuration metric[prometheus.Counter]
|
||||
searchDuration metric[prometheus.Counter]
|
||||
deleteDuration metric[prometheus.Counter]
|
||||
rangeDuration metric[prometheus.Counter]
|
||||
rangeHashDuration metric[prometheus.Counter]
|
||||
|
||||
putPayload prometheus.Counter
|
||||
getPayload prometheus.Counter
|
||||
putPayload metric[prometheus.Counter]
|
||||
getPayload metric[prometheus.Counter]
|
||||
|
||||
shardMetrics *prometheus.GaugeVec
|
||||
shardsReadonly *prometheus.GaugeVec
|
||||
shardMetrics metric[*prometheus.GaugeVec]
|
||||
shardsReadonly metric[*prometheus.GaugeVec]
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -49,13 +49,13 @@ const (
|
|||
|
||||
func newObjectMethodCallCounter(name string) methodCount {
|
||||
return methodCount{
|
||||
success: prometheus.NewCounter(prometheus.CounterOpts{
|
||||
success: newCounter(prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: objectSubsystem,
|
||||
Name: fmt.Sprintf("%s_req_count_success", name),
|
||||
Help: fmt.Sprintf("The number of successful %s requests processed", name),
|
||||
}),
|
||||
total: prometheus.NewCounter(prometheus.CounterOpts{
|
||||
total: newCounter(prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: objectSubsystem,
|
||||
Name: fmt.Sprintf("%s_req_count", name),
|
||||
|
@ -70,9 +70,9 @@ func (m methodCount) mustRegister() {
|
|||
}
|
||||
|
||||
func (m methodCount) Inc(success bool) {
|
||||
m.total.Inc()
|
||||
m.total.value.Inc()
|
||||
if success {
|
||||
m.success.Inc()
|
||||
m.success.value.Inc()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,8 +99,8 @@ func newObjectServiceMetrics() objectServiceMetrics {
|
|||
}
|
||||
}
|
||||
|
||||
func newObjectMethodPayloadCounter(method string) prometheus.Counter {
|
||||
return prometheus.NewCounter(prometheus.CounterOpts{
|
||||
func newObjectMethodPayloadCounter(method string) metric[prometheus.Counter] {
|
||||
return newCounter(prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: objectSubsystem,
|
||||
Name: fmt.Sprintf("%s_payload", method),
|
||||
|
@ -108,8 +108,8 @@ func newObjectMethodPayloadCounter(method string) prometheus.Counter {
|
|||
})
|
||||
}
|
||||
|
||||
func newObjectMethodDurationCounter(method string) prometheus.Counter {
|
||||
return prometheus.NewCounter(prometheus.CounterOpts{
|
||||
func newObjectMethodDurationCounter(method string) metric[prometheus.Counter] {
|
||||
return newCounter(prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: objectSubsystem,
|
||||
Name: fmt.Sprintf("%s_req_duration", method),
|
||||
|
@ -117,8 +117,8 @@ func newObjectMethodDurationCounter(method string) prometheus.Counter {
|
|||
})
|
||||
}
|
||||
|
||||
func newObjectGaugeVector(name, help string, labels []string) *prometheus.GaugeVec {
|
||||
return prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
func newObjectGaugeVector(name, help string, labels []string) metric[*prometheus.GaugeVec] {
|
||||
return newGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: objectSubsystem,
|
||||
Name: name,
|
||||
|
@ -179,43 +179,43 @@ func (m objectServiceMetrics) IncRangeHashReqCounter(success bool) {
|
|||
}
|
||||
|
||||
func (m objectServiceMetrics) AddGetReqDuration(d time.Duration) {
|
||||
m.getDuration.Add(float64(d))
|
||||
m.getDuration.value.Add(float64(d))
|
||||
}
|
||||
|
||||
func (m objectServiceMetrics) AddPutReqDuration(d time.Duration) {
|
||||
m.putDuration.Add(float64(d))
|
||||
m.putDuration.value.Add(float64(d))
|
||||
}
|
||||
|
||||
func (m objectServiceMetrics) AddHeadReqDuration(d time.Duration) {
|
||||
m.headDuration.Add(float64(d))
|
||||
m.headDuration.value.Add(float64(d))
|
||||
}
|
||||
|
||||
func (m objectServiceMetrics) AddSearchReqDuration(d time.Duration) {
|
||||
m.searchDuration.Add(float64(d))
|
||||
m.searchDuration.value.Add(float64(d))
|
||||
}
|
||||
|
||||
func (m objectServiceMetrics) AddDeleteReqDuration(d time.Duration) {
|
||||
m.deleteDuration.Add(float64(d))
|
||||
m.deleteDuration.value.Add(float64(d))
|
||||
}
|
||||
|
||||
func (m objectServiceMetrics) AddRangeReqDuration(d time.Duration) {
|
||||
m.rangeDuration.Add(float64(d))
|
||||
m.rangeDuration.value.Add(float64(d))
|
||||
}
|
||||
|
||||
func (m objectServiceMetrics) AddRangeHashReqDuration(d time.Duration) {
|
||||
m.rangeHashDuration.Add(float64(d))
|
||||
m.rangeHashDuration.value.Add(float64(d))
|
||||
}
|
||||
|
||||
func (m objectServiceMetrics) AddPutPayload(ln int) {
|
||||
m.putPayload.Add(float64(ln))
|
||||
m.putPayload.value.Add(float64(ln))
|
||||
}
|
||||
|
||||
func (m objectServiceMetrics) AddGetPayload(ln int) {
|
||||
m.getPayload.Add(float64(ln))
|
||||
m.getPayload.value.Add(float64(ln))
|
||||
}
|
||||
|
||||
func (m objectServiceMetrics) AddToObjectCounter(shardID, objectType string, delta int) {
|
||||
m.shardMetrics.With(
|
||||
m.shardMetrics.value.With(
|
||||
prometheus.Labels{
|
||||
shardIDLabelKey: shardID,
|
||||
counterTypeLabelKey: objectType,
|
||||
|
@ -224,7 +224,7 @@ func (m objectServiceMetrics) AddToObjectCounter(shardID, objectType string, del
|
|||
}
|
||||
|
||||
func (m objectServiceMetrics) SetObjectCounter(shardID, objectType string, v uint64) {
|
||||
m.shardMetrics.With(
|
||||
m.shardMetrics.value.With(
|
||||
prometheus.Labels{
|
||||
shardIDLabelKey: shardID,
|
||||
counterTypeLabelKey: objectType,
|
||||
|
@ -237,7 +237,7 @@ func (m objectServiceMetrics) SetReadonly(shardID string, readonly bool) {
|
|||
if readonly {
|
||||
flag = 1
|
||||
}
|
||||
m.shardsReadonly.With(
|
||||
m.shardsReadonly.value.With(
|
||||
prometheus.Labels{
|
||||
shardIDLabelKey: shardID,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue