Add metrics for tracking rendezvous method

Update tests for metrics

Add rendezvous_method to Prometheus metrics

Update broker spec docs with rendezvous method metrics

Bug fix
This commit is contained in:
Michael Pu 2024-01-28 17:09:08 -05:00 committed by Cecylia Bocovich
parent b8df42a377
commit 26ceb6e20d
No known key found for this signature in database
GPG key ID: 009DE379FD9B7B90
8 changed files with 355 additions and 30 deletions

View file

@ -161,7 +161,7 @@ func sendClientResponse(resp *messages.ClientPollResponse, response *[]byte) err
}
}
func (i *IPC) ClientOffers(arg messages.Arg, response *[]byte) error {
func (i *IPC) ClientOffers(arg messages.Arg, response *[]byte, rendezvousMethod RendezvousMethod) error {
startTime := time.Now()
req, err := messages.DecodeClientPollRequest(arg.Body)
@ -195,12 +195,12 @@ func (i *IPC) ClientOffers(arg messages.Arg, response *[]byte) error {
snowflake.offerChannel <- offer
} else {
i.ctx.metrics.lock.Lock()
i.ctx.metrics.clientDeniedCount++
i.ctx.metrics.promMetrics.ClientPollTotal.With(prometheus.Labels{"nat": offer.natType, "status": "denied"}).Inc()
i.ctx.metrics.clientDeniedCount[rendezvousMethod]++
i.ctx.metrics.promMetrics.ClientPollTotal.With(prometheus.Labels{"nat": offer.natType, "status": "denied", "rendezvous_method": string(rendezvousMethod)}).Inc()
if offer.natType == NATUnrestricted {
i.ctx.metrics.clientUnrestrictedDeniedCount++
i.ctx.metrics.clientUnrestrictedDeniedCount[rendezvousMethod]++
} else {
i.ctx.metrics.clientRestrictedDeniedCount++
i.ctx.metrics.clientRestrictedDeniedCount[rendezvousMethod]++
}
i.ctx.metrics.lock.Unlock()
resp := &messages.ClientPollResponse{Error: messages.StrNoProxies}
@ -211,8 +211,8 @@ func (i *IPC) ClientOffers(arg messages.Arg, response *[]byte) error {
select {
case answer := <-snowflake.answerChannel:
i.ctx.metrics.lock.Lock()
i.ctx.metrics.clientProxyMatchCount++
i.ctx.metrics.promMetrics.ClientPollTotal.With(prometheus.Labels{"nat": offer.natType, "status": "matched"}).Inc()
i.ctx.metrics.clientProxyMatchCount[rendezvousMethod]++
i.ctx.metrics.promMetrics.ClientPollTotal.With(prometheus.Labels{"nat": offer.natType, "status": "matched", "rendezvous_method": string(rendezvousMethod)}).Inc()
i.ctx.metrics.lock.Unlock()
resp := &messages.ClientPollResponse{Answer: answer}
err = sendClientResponse(resp, response)