better packaging
- update readme
This commit is contained in:
23
metrics.go
Normal file
23
metrics.go
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user