Пример #1
0
func (t *rpcType) Latest(
	path string, response *[]*messages.LatestMetric) error {
	apps, metricStore := t.AS.AllActiveWithStore()
	datastructs.ByHostAndName(apps)
	path = canonicalisePath(path)
	for _, app := range apps {
		*response = append(
			*response,
			latestMetricsForEndpoint(metricStore, app, path, false)...)
	}
	return nil
}
Пример #2
0
func (h latestHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()
	w.Header().Set("Content-Type", "application/json")
	path := canonicalisePath(r.URL.Path)
	apps, metricStore := h.AS.AllActiveWithStore()
	datastructs.ByHostAndName(apps)
	data := make([]*messages.LatestMetric, 0)
	for _, app := range apps {
		data = append(
			data,
			latestMetricsForEndpoint(metricStore, app, path, true)...)
	}
	encodeJson(w, data, r.Form.Get("format") == "text")
}