mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
proxy: add country to prometheus metrics
This commit is contained in:
parent
b3c734ed63
commit
e345c3bac9
6 changed files with 45 additions and 13 deletions
|
@ -15,16 +15,18 @@ const (
|
|||
type Metrics struct {
|
||||
totalInBoundTraffic prometheus.Counter
|
||||
totalOutBoundTraffic prometheus.Counter
|
||||
totalConnections prometheus.Counter
|
||||
totalConnections *prometheus.CounterVec
|
||||
}
|
||||
|
||||
func NewMetrics() *Metrics {
|
||||
return &Metrics{
|
||||
totalConnections: prometheus.NewCounter(prometheus.CounterOpts{
|
||||
totalConnections: prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: metricNamespace,
|
||||
Name: "connections_total",
|
||||
Help: "The total number of connections handled by the snowflake proxy",
|
||||
}),
|
||||
},
|
||||
[]string{"country"},
|
||||
),
|
||||
totalInBoundTraffic: prometheus.NewCounter(prometheus.CounterOpts{
|
||||
Namespace: metricNamespace,
|
||||
Name: "traffic_inbound_bytes_total",
|
||||
|
@ -71,6 +73,8 @@ func (m *Metrics) TrackOutBoundTraffic(value int64) {
|
|||
}
|
||||
|
||||
// TrackNewConnection counts the new connections
|
||||
func (m *Metrics) TrackNewConnection() {
|
||||
m.totalConnections.Inc()
|
||||
func (m *Metrics) TrackNewConnection(country string) {
|
||||
m.totalConnections.
|
||||
With(prometheus.Labels{"country": country}).
|
||||
Inc()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue