MCPcopy
hub / github.com/hwholiday/learning_tools / howie

Function howie

prometheus/server.go:47–62  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

45}
46
47func howie(w http.ResponseWriter, r *http.Request) {
48 httpRequestCount.WithLabelValues(r.URL.Path).Inc()
49 start := time.Now()
50 n := rand.Intn(100)
51 if n >= 90 {
52 orderNum.Dec()
53 time.Sleep(100 * time.Millisecond)
54 } else {
55 orderNum.Inc()
56 time.Sleep(50 * time.Millisecond)
57 }
58
59 elapsed := (float64)(time.Since(start) / time.Millisecond)
60 httpRequestDuration.WithLabelValues(r.URL.Path).Observe(elapsed)
61 w.Write([]byte("ok"))
62}

Callers

nothing calls this directly

Calls 1

WriteMethod · 0.80

Tested by

no test coverage detected