mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Add new gauge to show currently available proxies
This commit is contained in:
parent
92bd900bc5
commit
2a310682b5
2 changed files with 16 additions and 3 deletions
|
@ -151,6 +151,7 @@ func (ctx *BrokerContext) Broker() {
|
||||||
} else {
|
} else {
|
||||||
heap.Remove(ctx.restrictedSnowflakes, snowflake.index)
|
heap.Remove(ctx.restrictedSnowflakes, snowflake.index)
|
||||||
}
|
}
|
||||||
|
promMetrics.AvailableProxies.With(prometheus.Labels{"nat": request.natType, "type": request.proxyType}).Dec()
|
||||||
delete(ctx.idToSnowflake, snowflake.id)
|
delete(ctx.idToSnowflake, snowflake.id)
|
||||||
close(request.offerChannel)
|
close(request.offerChannel)
|
||||||
}
|
}
|
||||||
|
@ -176,6 +177,7 @@ func (ctx *BrokerContext) AddSnowflake(id string, proxyType string, natType stri
|
||||||
} else {
|
} else {
|
||||||
heap.Push(ctx.restrictedSnowflakes, snowflake)
|
heap.Push(ctx.restrictedSnowflakes, snowflake)
|
||||||
}
|
}
|
||||||
|
promMetrics.AvailableProxies.With(prometheus.Labels{"nat": natType, "type": proxyType}).Inc()
|
||||||
ctx.snowflakeLock.Unlock()
|
ctx.snowflakeLock.Unlock()
|
||||||
ctx.idToSnowflake[id] = snowflake
|
ctx.idToSnowflake[id] = snowflake
|
||||||
return snowflake
|
return snowflake
|
||||||
|
@ -319,6 +321,7 @@ func clientOffers(ctx *BrokerContext, w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.snowflakeLock.Lock()
|
ctx.snowflakeLock.Lock()
|
||||||
|
promMetrics.AvailableProxies.With(prometheus.Labels{"nat": snowflake.natType, "type": snowflake.proxyType}).Dec()
|
||||||
delete(ctx.idToSnowflake, snowflake.id)
|
delete(ctx.idToSnowflake, snowflake.id)
|
||||||
ctx.snowflakeLock.Unlock()
|
ctx.snowflakeLock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,6 +264,7 @@ type PromMetrics struct {
|
||||||
ProxyTotal *prometheus.CounterVec
|
ProxyTotal *prometheus.CounterVec
|
||||||
ProxyPollTotal *RoundedCounterVec
|
ProxyPollTotal *RoundedCounterVec
|
||||||
ClientPollTotal *RoundedCounterVec
|
ClientPollTotal *RoundedCounterVec
|
||||||
|
AvailableProxies *prometheus.GaugeVec
|
||||||
}
|
}
|
||||||
|
|
||||||
//Initialize metrics for prometheus exporter
|
//Initialize metrics for prometheus exporter
|
||||||
|
@ -280,6 +281,15 @@ func initPrometheus() *PromMetrics {
|
||||||
[]string{"type", "nat", "cc"},
|
[]string{"type", "nat", "cc"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
promMetrics.AvailableProxies = promauto.NewGaugeVec(
|
||||||
|
prometheus.GaugeOpts{
|
||||||
|
Namespace: prometheusNamespace,
|
||||||
|
Name: "available_proxies",
|
||||||
|
Help: "The number of currently available snowflake proxies",
|
||||||
|
},
|
||||||
|
[]string{"type", "nat"},
|
||||||
|
)
|
||||||
|
|
||||||
promMetrics.ProxyPollTotal = NewRoundedCounterVec(
|
promMetrics.ProxyPollTotal = NewRoundedCounterVec(
|
||||||
prometheus.CounterOpts{
|
prometheus.CounterOpts{
|
||||||
Namespace: prometheusNamespace,
|
Namespace: prometheusNamespace,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue