Files
cachet-monitor/metrics.go
Matej Kramny 2d62fc7443 refactoring
2016-05-19 12:20:56 +01:00

26 lines
514 B
Go

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