Skip to content

Commit

Permalink
docs: better comments in metrics middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
samlaf committed Oct 30, 2024
1 parent 5960858 commit e7bc95c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

// withMetrics is a middleware that records metrics for the route path.
// It does not write anything to the response, that is the job of the handlers.
func withMetrics(
handleFn func(http.ResponseWriter, *http.Request) error,
m metrics.Metricer,
Expand All @@ -30,9 +31,10 @@ func withMetrics(
}
return err
}
// we assume that every route will set the status header
// TODO: some routes don't have a version byte, such as /put simple commitments
versionByte, err := parseVersionByte(w, r)
if err != nil {
// we assume that every route will set the status header
recordDur(w.Header().Get("status"), string(mode), string(versionByte))
return fmt.Errorf("metrics middleware: error parsing version byte: %w", err)
}
Expand Down

0 comments on commit e7bc95c

Please sign in to comment.