MM-23131 Include HTTP status code in the metrics (#14240)

* ResponseWriter wrapper to get status code

For our metrics, we need the status code returned by a request
so this wrapper includes a new method StatusCode() that includes
the desired code

* Shadow the responsewriter variable in the handlers

In order to avoid confusion to people deciding what variable to use.
I've also changed the tests to reflect this change and added a new
one that checks the Flush method works
Этот коммит содержится в:
Mario de Frutos Dieguez
2020-04-14 14:15:00 +02:00
коммит произвёл GitHub
родитель 53c1c0d4b4
Коммит aafea55976
5 изменённых файлов: 157 добавлений и 5 удалений

Просмотреть файл

@@ -48,7 +48,7 @@ type MetricsInterface interface {
IncrementPostsSearchCounter()
ObservePostsSearchDuration(elapsed float64)
ObserveStoreMethodDuration(method, success string, elapsed float64)
ObserveApiEndpointDuration(endpoint, method string, elapsed float64)
ObserveApiEndpointDuration(endpoint, method, statusCode string, elapsed float64)
IncrementPostIndexCounter()
IncrementUserIndexCounter()
IncrementChannelIndexCounter()