@@ -2395,6 +2395,33 @@ func (h *Handler) serveExpvar(w http.ResponseWriter, r *http.Request) {
23952395 uniqueKeys := make (map [string ]int )
23962396
23972397 for _ , s := range stats {
2398+ if s .Name == "cq" {
2399+ jv , err := parseCQStatistics (& s .Statistic )
2400+ if err != nil {
2401+ h .httpError (w , err .Error (), http .StatusInternalServerError )
2402+ return
2403+ }
2404+ data , err := json .Marshal (jv )
2405+ if err != nil {
2406+ h .httpError (w , err .Error (), http .StatusInternalServerError )
2407+ return
2408+ }
2409+
2410+ if ! first {
2411+ _ , err := fmt .Fprintln (w , "," )
2412+ if err != nil {
2413+ h .httpError (w , err .Error (), http .StatusInternalServerError )
2414+ return
2415+ }
2416+ }
2417+ first = false
2418+ _ , err = fmt .Fprintf (w , "\" cq\" : %s" , data )
2419+ if err != nil {
2420+ h .httpError (w , err .Error (), http .StatusInternalServerError )
2421+ return
2422+ }
2423+ continue
2424+ }
23982425 val , err := json .Marshal (s )
23992426 if err != nil {
24002427 continue
@@ -2644,6 +2671,14 @@ func parseConfigDiagnostics(d *diagnostics.Diagnostics) (map[string]interface{},
26442671 return m , nil
26452672}
26462673
2674+ func parseCQStatistics (s * models.Statistic ) (map [string ]interface {}, error ) {
2675+ if len (s .Values ) == 0 {
2676+ return nil , fmt .Errorf ("no cq statistics data available" )
2677+ }
2678+
2679+ return s .Values , nil
2680+ }
2681+
26472682// httpError writes an error to the client in a standard format.
26482683func (h * Handler ) httpError (w http.ResponseWriter , errmsg string , code int ) {
26492684 if code == http .StatusUnauthorized {
0 commit comments