mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-25 00:06:46 +00:00
introduce a cheap /api/probes?sparse variant
In many cases we only need to know whether there are _any_ connected probes, and not the probe details. Obtaining that info is cheaper since it requires no reading or merging or reports.
This commit is contained in:
@@ -32,6 +32,16 @@ type probeDesc struct {
|
||||
// Probe handler
|
||||
func makeProbeHandler(rep Reporter) CtxHandlerFunc {
|
||||
return func(ctx context.Context, w http.ResponseWriter, r *http.Request) {
|
||||
r.ParseForm()
|
||||
if _, sparse := r.Form["sparse"]; sparse {
|
||||
// if we have reports, we must have connected probes
|
||||
hasProbes, err := rep.HasReports(ctx, time.Now())
|
||||
if err != nil {
|
||||
respondWith(w, http.StatusInternalServerError, err)
|
||||
}
|
||||
respondWith(w, http.StatusOK, hasProbes)
|
||||
return
|
||||
}
|
||||
rpt, err := rep.Report(ctx, time.Now())
|
||||
if err != nil {
|
||||
respondWith(w, http.StatusInternalServerError, err)
|
||||
|
||||
Reference in New Issue
Block a user