Copilot commented on code in PR #750:
URL: https://github.com/apache/dubbo-go-pixiu/pull/750#discussion_r2317889021


##########
pkg/prometheus/prometheus.go:
##########
@@ -268,7 +268,8 @@ func (p *Prometheus) registerMetrics() {
 }
 
 func (p *Prometheus) SetPushGatewayUrl(pushGatewayURL, metricspath string) {
-
+       p.Ppg.mutex.Lock()
+       defer p.Ppg.mutex.Unlock()

Review Comment:
   The mutex field 'mutex' is not defined in the PushGateway struct. This code 
will fail to compile as the mutex field doesn't exist.



##########
pkg/prometheus/prometheus.go:
##########
@@ -323,6 +326,8 @@ func (p *Prometheus) sendMetricsToPushGateway(metrics 
[]byte) {
 }
 
 func (p *Prometheus) getPushGatewayURL() string {
+       p.Ppg.mutex.RLock()
+       defer p.Ppg.mutex.RUnlock()

Review Comment:
   The mutex field 'mutex' is not defined in the PushGateway struct. This code 
will fail to compile as the mutex field doesn't exist.



##########
pkg/prometheus/prometheus.go:
##########
@@ -220,7 +220,7 @@ type Prometheus struct {
 // PushGateway contains the configuration for pushing to a Prometheus 
pushgateway (optional)
 type PushGateway struct {
        CounterPush           bool
-       PushIntervalSeconds   time.Duration
+       PushInterval          time.Duration

Review Comment:
   The PR title contains a typo: 'protencial' should be 'potential'.



##########
pkg/prometheus/prometheus.go:
##########
@@ -279,6 +280,8 @@ func (p *Prometheus) SetPushIntervalThreshold(isTurn bool, 
pushIntervalThreshold
 }
 
 func (p *Prometheus) SetPushGatewayJob(j string) {
+       p.Ppg.mutex.Lock()
+       defer p.Ppg.mutex.Unlock()

Review Comment:
   The mutex field 'mutex' is not defined in the PushGateway struct. This code 
will fail to compile as the mutex field doesn't exist.



##########
pkg/prometheus/prometheus.go:
##########
@@ -323,6 +326,8 @@ func (p *Prometheus) sendMetricsToPushGateway(metrics 
[]byte) {
 }
 
 func (p *Prometheus) getPushGatewayURL() string {
+       p.Ppg.mutex.RLock()
+       defer p.Ppg.mutex.RUnlock()
        h, _ := os.Hostname()
        if p.Ppg.Job == "" {
                p.Ppg.Job = "pixiu"

Review Comment:
   This code modifies p.Ppg.Job while holding a read lock (RLock), but 
modification requires a write lock (Lock). This will cause a race condition.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to