Skip to content

Commit

Permalink
Merge pull request #79 from aaronkan007/master
Browse files Browse the repository at this point in the history
Fix conncount metrics Inc/Dec
  • Loading branch information
niubell authored Jan 16, 2022
2 parents b511fd4 + a8ff941 commit 89d789c
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions pkg/proxy/namespace/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ package namespace
import (
"context"
"fmt"
"sync/atomic"

"github.com/pingcap/errors"
"github.com/tidb-incubator/weir/pkg/config"
"github.com/tidb-incubator/weir/pkg/proxy/driver"
"github.com/tidb-incubator/weir/pkg/proxy/metrics"
"github.com/pingcap/errors"
)

type NamespaceHolder struct {
Expand All @@ -18,7 +16,6 @@ type NamespaceHolder struct {
type NamespaceWrapper struct {
nsmgr *NamespaceManager
name string
connCounter int64
}

func CreateNamespaceHolder(cfgs []*config.Namespace, build NamespaceBuilder) (*NamespaceHolder, error) {
Expand Down Expand Up @@ -86,13 +83,11 @@ func (n *NamespaceWrapper) GetPooledConn(ctx context.Context) (driver.PooledBack
}

func (n *NamespaceWrapper) IncrConnCount() {
currCnt := atomic.AddInt64(&n.connCounter, 1)
metrics.QueryCtxGauge.WithLabelValues(n.name).Set(float64(currCnt))
metrics.QueryCtxGauge.WithLabelValues(n.name).Inc()
}

func (n *NamespaceWrapper) DescConnCount() {
currCnt := atomic.AddInt64(&n.connCounter, -1)
metrics.QueryCtxGauge.WithLabelValues(n.name).Set(float64(currCnt))
metrics.QueryCtxGauge.WithLabelValues(n.name).Dec()
}

func (n *NamespaceWrapper) Closed() bool {
Expand Down

0 comments on commit 89d789c

Please sign in to comment.