MCPcopy Index your code
hub / github.com/InferCore/InferCore / withRequestLoggingAndMetrics

Method withRequestLoggingAndMetrics

internal/server/server.go:752–762  ·  view source on GitHub ↗
(next http.Handler)

Source from the content-addressed store, hash-verified

750}
751
752func (s *Server) withRequestLoggingAndMetrics(next http.Handler) http.Handler {
753 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
754 start := time.Now()
755 rec := &statusRecorder{ResponseWriter: w, statusCode: http.StatusOK}
756 next.ServeHTTP(rec, r)
757
758 statusCode := rec.statusCode
759 s.recordHTTPMetric(r.URL.Path, r.Method, statusCode)
760 log.Printf("event=http_request path=%s method=%s status=%d latency_ms=%d", r.URL.Path, r.Method, statusCode, time.Since(start).Milliseconds())
761 })
762}
763
764func (s *Server) recordHTTPMetric(path, method string, statusCode int) {
765 if s.httpReqCounter == nil {

Callers 1

RoutesMethod · 0.95

Calls 1

recordHTTPMetricMethod · 0.95

Tested by

no test coverage detected