You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/11/29 02:21:23 UTC
[GitHub] [dubbo-go-pixiu] baerwang commented on a diff in pull request #528: Optimizing Metric Implementation
baerwang commented on code in PR #528:
URL: https://github.com/apache/dubbo-go-pixiu/pull/528#discussion_r1034236406
##########
pkg/metrics/prometheus/prometheus.go:
##########
@@ -261,40 +263,41 @@ func (p *Prometheus) registerMetrics() {
}
}
-func (p *Prometheus) SetMetricPath(path string) {
- p.MetricsPath = path
-}
-
-func (p *Prometheus) SetPushGatewayUrl(pushGatewayURL, metricsURL string, pushInterval time.Duration) {
+func (p *Prometheus) SetPushGatewayUrl(pushGatewayURL, metricspath string) {
p.Ppg.PushGatewayURL = pushGatewayURL
- p.MetricsPath = metricsURL
- p.Ppg.PushInterval = pushInterval
- p.MetricsPath = metricsURL
-
+ p.MetricsPath = metricspath
}
-func (p *Prometheus) SetPushGateway() {
- p.startPushTicker()
+func (p *Prometheus) SetPushIntervalThreshold(isTurn bool, pushIntervalThreshold int) {
+ p.Ppg.CounterPush = isTurn
+ p.Ppg.PushIntervalThreshold = pushIntervalThreshold
}
func (p *Prometheus) SetPushGatewayJob(j string) {
p.Ppg.Job = j
}
-func (p *Prometheus) startPushTicker() {
- p.sendMetricsToPushGateway(p.getMetrics())
+func (p *Prometheus) startPushCounter() {
+ if p.Ppg.counter >= p.Ppg.PushIntervalThreshold {
+ go p.sendMetricsToPushGateway(p.getMetrics())
+ p.Ppg.counter = 0
+ }
}
-func (p *Prometheus) getMetrics() []byte {
+func (p *Prometheus) SetPushGateway() {
+ if p.Ppg.CounterPush {
+ p.startPushCounter()
+ }
+}
+func (p *Prometheus) getMetrics() []byte {
out := &bytes.Buffer{}
metricFamilies, _ := prometheus.DefaultGatherer.Gather()
Review Comment:
def new error field,use it
##########
pkg/metrics/prometheus/prometheus.go:
##########
@@ -19,7 +19,6 @@ package prometheus
Review Comment:
will file move pixiu/pkg/
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org