better packaging

- update readme
This commit is contained in:
Matej Kramny
2016-05-18 23:54:55 +01:00
parent 025d0c5822
commit 267a6cb6b3
10 changed files with 52 additions and 83 deletions

23
metrics.go Normal file
View File

@@ -0,0 +1,23 @@
package cachet
import (
"encoding/json"
"strconv"
)
// SendMetric sends lag metric point
func SendMetric(metricID int, delay int64) {
if metricID <= 0 {
return
}
jsonBytes, _ := json.Marshal(&map[string]interface{}{
"value": delay,
})
resp, _, err := makeRequest("POST", "/metrics/"+strconv.Itoa(metricID)+"/points", jsonBytes)
if err != nil || resp.StatusCode != 200 {
Logger.Printf("Could not log data point!\n%v\n", err)
return
}
}