mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Implemented count metrics for broker events
Added three new metrics: - proxyIdleCount counts the number of times a proxy polls and receives no snowflakes - clientDeniedCount counts the number of times a client requested a snowflake but none were available - clientProxyMatchCount counts the number of times a client successfully received a snowflake
This commit is contained in:
parent
64ce7dff1b
commit
d57cd07599
2 changed files with 29 additions and 14 deletions
|
@ -153,6 +153,7 @@ func proxyPolls(ctx *BrokerContext, w http.ResponseWriter, r *http.Request) {
|
|||
offer := ctx.RequestOffer(id)
|
||||
if nil == offer {
|
||||
log.Println("Proxy " + id + " did not receive a Client offer.")
|
||||
ctx.metrics.proxyIdleCount++
|
||||
w.WriteHeader(http.StatusGatewayTimeout)
|
||||
return
|
||||
}
|
||||
|
@ -176,6 +177,7 @@ func clientOffers(ctx *BrokerContext, w http.ResponseWriter, r *http.Request) {
|
|||
// Immediately fail if there are no snowflakes available.
|
||||
if ctx.snowflakes.Len() <= 0 {
|
||||
log.Println("Client: No snowflake proxies available.")
|
||||
ctx.metrics.clientDeniedCount++
|
||||
w.WriteHeader(http.StatusServiceUnavailable)
|
||||
return
|
||||
}
|
||||
|
@ -189,6 +191,7 @@ func clientOffers(ctx *BrokerContext, w http.ResponseWriter, r *http.Request) {
|
|||
select {
|
||||
case answer := <-snowflake.answerChannel:
|
||||
log.Println("Client: Retrieving answer")
|
||||
ctx.metrics.clientProxyMatchCount++
|
||||
w.Write(answer)
|
||||
// Initial tracking of elapsed time.
|
||||
ctx.metrics.clientRoundtripEstimate = time.Since(startTime) /
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue