MCPcopy
hub / github.com/grafana/tempo / readyHandler

Method readyHandler

cmd/tempo/app/app.go:327–375  ·  view source on GitHub ↗
(sm *services.Manager, shutdownRequested *atomic.Bool)

Source from the content-addressed store, hash-verified

325}
326
327func (t *App) readyHandler(sm *services.Manager, shutdownRequested *atomic.Bool) http.HandlerFunc {
328 return func(w http.ResponseWriter, r *http.Request) {
329 if shutdownRequested.Load() {
330 level.Debug(util_log.Logger).Log("msg", "application is stopping")
331 http.Error(w, "Application is stopping", http.StatusServiceUnavailable)
332 return
333 }
334
335 if !sm.IsHealthy() {
336 msg := bytes.Buffer{}
337 msg.WriteString("Some services are not Running:\n")
338
339 byState := sm.ServicesByState()
340 for st, ls := range byState {
341 msg.WriteString(fmt.Sprintf("%v: %d\n", st, len(ls)))
342 }
343
344 http.Error(w, msg.String(), http.StatusServiceUnavailable)
345 return
346 }
347
348 if t.generator != nil {
349 if err := t.generator.CheckReady(r.Context()); err != nil {
350 http.Error(w, "Generator not ready: "+err.Error(), http.StatusServiceUnavailable)
351 return
352 }
353 }
354
355 // Query Frontend has a special check that makes sure that a querier is attached before it signals
356 // itself as ready
357 if t.frontend != nil {
358 if err := t.frontend.CheckReady(r.Context()); err != nil {
359 http.Error(w, "Query Frontend not ready: "+err.Error(), http.StatusServiceUnavailable)
360 return
361 }
362 }
363
364 // LiveStore has a special check that makes sure it has caught up with Kafka
365 // before serving queries.
366 if t.liveStore != nil {
367 if err := t.liveStore.CheckReady(r.Context()); err != nil {
368 http.Error(w, "LiveStore not ready: "+err.Error(), http.StatusServiceUnavailable)
369 return
370 }
371 }
372
373 http.Error(w, "ready", http.StatusOK)
374 }
375}
376
377func (t *App) writeRuntimeConfig(w io.Writer, r *http.Request) error {
378 // Querier and query-frontend services do not run the overrides module

Callers 1

RunMethod · 0.95

Calls 5

LogMethod · 0.65
ErrorMethod · 0.65
ContextMethod · 0.65
StringMethod · 0.45
CheckReadyMethod · 0.45

Tested by

no test coverage detected