MCPcopy Create free account
hub / github.com/couchbase/cbft / ServeHTTP

Method ServeHTTP

prometheus.go:99–135  ·  view source on GitHub ↗
(w http.ResponseWriter,
	req *http.Request)

Source from the content-addressed store, hash-verified

97}
98
99func (h *PrometheusHighMetricsHandler) ServeHTTP(w http.ResponseWriter,
100 req *http.Request) {
101 initNsServerCaching(h.mgr)
102
103 rd := getRecentInfo()
104 if rd.err != nil {
105 rest.ShowError(w, req, fmt.Sprintf("could not retrieve defs: %v", rd.err),
106 http.StatusInternalServerError)
107 return
108 }
109
110 nsIndexStats, err := gatherIndexStats(h.mgr, rd, true)
111 if err != nil {
112 rest.ShowError(w, req, fmt.Sprintf("error in retrieving defs: %v", err),
113 http.StatusInternalServerError)
114 return
115 }
116
117 w.Header().Set("Cache-Control", "no-cache")
118 w.Header().Set("Content-Type", "text/plain; charset=utf-8")
119
120 for k, nsis := range nsIndexStats {
121 for nsik, nsiv := range nsis {
122 b, err := json.Marshal(nsiv)
123 if err != nil {
124 rest.ShowError(w, req, fmt.Sprintf("json marshal err: %v", err),
125 http.StatusInternalServerError)
126 return
127 }
128 if typ, ok := prometheusStats[nsik]; ok {
129 w.Write([]byte(fmt.Sprintf("# TYPE fts_%s %s\n", nsik, typ)))
130 w.Write(append([]byte("fts_"+nsik+k+" "), b...))
131 w.Write(bline)
132 }
133 }
134 }
135}
136
137func scopeCollNames(params, sourceName string) (string, []string) {
138 tmp := struct {

Callers

nothing calls this directly

Calls 6

initNsServerCachingFunction · 0.85
getRecentInfoFunction · 0.85
gatherIndexStatsFunction · 0.85
HeaderMethod · 0.80
MarshalMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected