-
Notifications
You must be signed in to change notification settings - Fork 726
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) close #6136, ref #6170 Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com> Signed-off-by: lhy1024 <admin@liudos.us> Co-authored-by: Yongbo Jiang <cabinfeveroier@gmail.com> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io> Co-authored-by: lhy1024 <admin@liudos.us>
- Loading branch information
1 parent
c6ea772
commit 64761de
Showing
5 changed files
with
125 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright 2023 TiKV Project Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package controller | ||
|
||
import "github.com/prometheus/client_golang/prometheus" | ||
|
||
const ( | ||
namespace = "resource_manager_client" | ||
requestSubsystem = "request" | ||
tokenRequestSubsystem = "token_request" | ||
|
||
resourceGroupNameLabel = "name" | ||
) | ||
|
||
var ( | ||
resourceGroupStatusGauge = prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Subsystem: "resource_group", | ||
Name: "status", | ||
Help: "Status of the resource group.", | ||
}, []string{resourceGroupNameLabel}) | ||
|
||
successfulRequestDuration = prometheus.NewHistogramVec( | ||
prometheus.HistogramOpts{ | ||
Namespace: namespace, | ||
Subsystem: requestSubsystem, | ||
Name: "success", | ||
Buckets: prometheus.ExponentialBuckets(0.001, 4, 8), // 0.001 ~ 40.96 | ||
Help: "Bucketed histogram of wait duration of successful request.", | ||
}, []string{resourceGroupNameLabel}) | ||
|
||
failedRequestCounter = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: requestSubsystem, | ||
Name: "fail", | ||
Help: "Counter of failed request.", | ||
}, []string{resourceGroupNameLabel}) | ||
|
||
tokenRequestDuration = prometheus.NewHistogramVec( | ||
prometheus.HistogramOpts{ | ||
Namespace: namespace, | ||
Subsystem: tokenRequestSubsystem, | ||
Name: "duration", | ||
Help: "Bucketed histogram of latency(s) of token request.", | ||
}, []string{"type"}) | ||
|
||
resourceGroupTokenRequestCounter = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: tokenRequestSubsystem, | ||
Name: "resource_group", | ||
Help: "Counter of token request by every resource group.", | ||
}, []string{resourceGroupNameLabel}) | ||
) | ||
|
||
var ( | ||
// WithLabelValues is a heavy operation, define variable to avoid call it every time. | ||
failedTokenRequestDuration = tokenRequestDuration.WithLabelValues("fail") | ||
successfulTokenRequestDuration = tokenRequestDuration.WithLabelValues("success") | ||
) | ||
|
||
func init() { | ||
prometheus.MustRegister(resourceGroupStatusGauge) | ||
prometheus.MustRegister(successfulRequestDuration) | ||
prometheus.MustRegister(failedRequestCounter) | ||
prometheus.MustRegister(tokenRequestDuration) | ||
prometheus.MustRegister(resourceGroupTokenRequestCounter) | ||
} |