From 215f33d8627458fcc86daa60b0a40eece26e200f Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Wed, 15 Feb 2017 00:48:05 -0500 Subject: [PATCH] frontend/*: only record ClientErrors to Prometheus All ClientErrors are constant and should not cause Prometheus streams to be generated for all possible failure scenarios in the program. Fixes #294. --- frontend/http/frontend.go | 6 +++++- frontend/udp/frontend.go | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/http/frontend.go b/frontend/http/frontend.go index 8ff5998..914d2a4 100644 --- a/frontend/http/frontend.go +++ b/frontend/http/frontend.go @@ -39,7 +39,11 @@ var promResponseDurationMilliseconds = prometheus.NewHistogramVec( func recordResponseDuration(action string, af *bittorrent.AddressFamily, err error, duration time.Duration) { var errString string if err != nil { - errString = err.Error() + if _, ok := err.(bittorrent.ClientError); ok { + errString = err.Error() + } else { + errString = "internal error" + } } var afString string diff --git a/frontend/udp/frontend.go b/frontend/udp/frontend.go index 405d1ca..bbeb648 100644 --- a/frontend/udp/frontend.go +++ b/frontend/udp/frontend.go @@ -42,7 +42,11 @@ var promResponseDurationMilliseconds = prometheus.NewHistogramVec( func recordResponseDuration(action string, af *bittorrent.AddressFamily, err error, duration time.Duration) { var errString string if err != nil { - errString = err.Error() + if _, ok := err.(bittorrent.ClientError); ok { + errString = err.Error() + } else { + errString = "internal error" + } } var afString string