MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / StartServer

Method StartServer

monitoring/prometheus/prometheus.go:151–171  ·  view source on GitHub ↗

StartServer starts the Prometheus metrics server

(cancel context.CancelFunc)

Source from the content-addressed store, hash-verified

149
150// StartServer starts the Prometheus metrics server
151func (p *Prometheus) StartServer(cancel context.CancelFunc) error {
152 s := http.Server{
153 ReadHeaderTimeout: 5 * time.Second,
154 Handler: promhttp.Handler(),
155 }
156
157 l, err := net.Listen("tcp", p.config.Bind)
158 if err != nil {
159 return fmt.Errorf("can't start Prometheus metrics server: %w", err)
160 }
161
162 go func() {
163 slog.Info(fmt.Sprintf("Starting Prometheus server at %s", p.config.Bind))
164 if err := s.Serve(l); err != nil && !errors.Is(err, http.ErrServerClosed) {
165 slog.Error(err.Error())
166 }
167 cancel()
168 }()
169
170 return nil
171}
172
173// StartRequest starts a new request for Prometheus monitoring
174func (p *Prometheus) StartRequest(

Callers 1

StartPrometheusMethod · 0.45

Calls 2

ErrorfMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected