diff options
author | Anton Evangelatov <anton.evangelatov@gmail.com> | 2018-02-23 21:19:59 +0800 |
---|---|---|
committer | Balint Gabor <balint.g@gmail.com> | 2018-02-23 21:19:59 +0800 |
commit | dcca613a0b4c6ce56e52f4607cf71f4f1338db8f (patch) | |
tree | 298e858e042df9d515aa091a79902ee9bf6d9f7b /swarm/api/http/error.go | |
parent | b677a07d36c957c4221bae952189559ac0c70537 (diff) | |
download | go-tangerine-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar go-tangerine-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar.gz go-tangerine-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar.bz2 go-tangerine-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar.lz go-tangerine-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar.xz go-tangerine-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.tar.zst go-tangerine-dcca613a0b4c6ce56e52f4607cf71f4f1338db8f.zip |
swarm: initial instrumentation (#15969)
* swarm: initial instrumentation with go-metrics
* swarm: initialise metrics collection and add ResettingTimer to HTTP requests
* swarm: update metrics flags names. remove redundant Timer.
* swarm: rename method for periodically updating gauges
* swarm: finalise metrics after feedback
* swarm/network: always init kad metrics containers
* swarm/network: off-by-one index in metrics containers
* swarm, metrics: resolved conflicts
Diffstat (limited to 'swarm/api/http/error.go')
-rw-r--r-- | swarm/api/http/error.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/swarm/api/http/error.go b/swarm/api/http/error.go index dbd97182f..831cf23fe 100644 --- a/swarm/api/http/error.go +++ b/swarm/api/http/error.go @@ -29,12 +29,19 @@ import ( "time" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/swarm/api" ) //templateMap holds a mapping of an HTTP error code to a template var templateMap map[int]*template.Template +//metrics variables +var ( + htmlCounter = metrics.NewRegisteredCounter("api.http.errorpage.html.count", nil) + jsonCounter = metrics.NewRegisteredCounter("api.http.errorpage.json.count", nil) +) + //parameters needed for formatting the correct HTML page type ErrorParams struct { Msg string @@ -132,6 +139,7 @@ func respond(w http.ResponseWriter, r *http.Request, params *ErrorParams) { //return a HTML page func respondHtml(w http.ResponseWriter, params *ErrorParams) { + htmlCounter.Inc(1) err := params.template.Execute(w, params) if err != nil { log.Error(err.Error()) @@ -140,6 +148,7 @@ func respondHtml(w http.ResponseWriter, params *ErrorParams) { //return JSON func respondJson(w http.ResponseWriter, params *ErrorParams) { + jsonCounter.Inc(1) w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(params) } |