diff options
author | Emile <hanemile@protonmail.com> | 2019-02-07 02:45:33 +0100 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2019-02-07 02:45:33 +0100 |
commit | d2d08cecf4746a53df305fb67468919ef9657836 (patch) | |
tree | 29b2823fc9137d9b6566f63a36091f62d62068e6 /metrics.go | |
parent | 515aeb56e414b4dc43a58171a93c3eaebdcd1906 (diff) |
new model, see the wiki for a description how this all works
Diffstat (limited to 'metrics.go')
-rw-r--r-- | metrics.go | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/metrics.go b/metrics.go deleted file mode 100644 index 5d04517..0000000 --- a/metrics.go +++ /dev/null @@ -1,45 +0,0 @@ -package main - -import ( - "fmt" - "log" - "net/http" - "net/url" -) - -// metricHandler prints all the metrics to the ResponseWriter -func metricHandler(w http.ResponseWriter, r *http.Request) { - var metricsString string - metricsString += fmt.Sprintf("nr_galaxies %d\n", len(treeArray)) - - for i := 0; i < len(starCount); i++ { - metricsString += fmt.Sprintf("galaxy_star_count{galaxy_nr=\"%d\"} %d\n", i, starCount[i]) - } - - for i := 0; i < len(errorCount); i++ { - metricsString += fmt.Sprintf("galaxy_error_count{galaxy_nr=\"%d\"} %d\n", i, errorCount[i]) - } - - log.Println(metricsString) - _, _ = fmt.Fprintf(w, metricsString) -} - -// pushMetricsNumOfStars pushes the amount of stars in the given galaxy with the given index to the given host -// the host is (normally) the service bundling the metrics -func pushMetricsNumOfStars(host string, treeindex int64) { - - // define a post-request and send it to the given host - requestURL := fmt.Sprintf("%s", host) - resp, err := http.PostForm(requestURL, - url.Values{ - "key": {fmt.Sprintf("db_%s{nr=\"%s\"}", "stars_num", treeindex)}, - "value": {fmt.Sprintf("%d", starCount[treeindex])}, - }, - ) - if err != nil { - fmt.Printf("Cound not make a POST request to %s", requestURL) - } - - // close the response body - defer resp.Body.Close() -} |