diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2021-12-17 17:47:19 +0300 |
---|---|---|
committer | Pavlo Strokov <pstrokov@gitlab.com> | 2022-01-06 10:59:58 +0300 |
commit | 241fd5a1bb2c3a96d1bfdc325dd3daed106a12c9 (patch) | |
tree | fc94f337798298b8abb300ca4f5172f402956a23 /internal/connectioncounter | |
parent | 7bb80f713fccac70cd4f17211f1f5435b5014c7a (diff) |
metrics: Total amount of connections to the service
The existing metric 'gitaly_connections_total' exists
on a package level (the global metric) and used for
both praefect and gitaly services. With this change
we address both those problems: the metric now are
local to the service and a new metric introduced
specially for praefect following the same naming
pattern as all other praefect-related metrics.
The content of the connectioncounter package moved
into a starter package as it makes no sense to have
it separately.
Change: added
Diffstat (limited to 'internal/connectioncounter')
-rw-r--r-- | internal/connectioncounter/connectioncounter.go | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/internal/connectioncounter/connectioncounter.go b/internal/connectioncounter/connectioncounter.go deleted file mode 100644 index 4c58fceff..000000000 --- a/internal/connectioncounter/connectioncounter.go +++ /dev/null @@ -1,37 +0,0 @@ -package connectioncounter - -import ( - "net" - - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/client_golang/prometheus/promauto" -) - -var connTotal = promauto.NewCounterVec( - prometheus.CounterOpts{ - Name: "gitaly_connections_total", - Help: "Total number of connections accepted by this Gitaly process", - }, - []string{"type"}, -) - -// New returns a listener which increments a prometheus counter on each -// accepted connection. Use cType to specify the connection type, this is -// a prometheus label. -func New(cType string, l net.Listener) net.Listener { - return &countingListener{ - cType: cType, - Listener: l, - } -} - -type countingListener struct { - net.Listener - cType string -} - -func (cl *countingListener) Accept() (net.Conn, error) { - conn, err := cl.Listener.Accept() - connTotal.WithLabelValues(cl.cType).Inc() - return conn, err -} |