Exemplo n.º 1
0
func (r *Reporter) Drop(rep *report.Report) (err error) {
	if !r.noop {
		v := url.Values{
			"title":       {rep.Key()},
			"description": {rep.Value()},
			"start_time":  {fmt.Sprintf("%d", rep.When().Unix())},
			"tag":         rep.Meta(),
		}
		res, err := r.cli.PostForm(r.endpoint, v)
		logx.OnFatal(err)
		bd, _ := ioutil.ReadAll(res.Body)
		bds := string(bd[:len(bd)])
		res.Body.Close()
		if bds != "" {
			logx.Fatal(bds)
		}
		logx.Infof("annotation sent: %+v", rep)
	} else {
		logx.Infof("annotation: %+v", rep)
	}
	return
}
Exemplo n.º 2
0
func (r *Reporter) Drop(rep *report.Report) (err error) {
	if !r.noop {

		if err = r.connect(); err != nil {
			logx.Error(err)
			return
		}
		_, err = fmt.Fprintf(r.conn, "%s.%s %s %d",
			strings.Join(rep.Meta(), "."), rep.Key(),
			rep.Value(), rep.When().Unix())
		logx.Debugf("datapoint sent: %+v", rep)
		if err != nil {
			logx.Error(err)
			r.conn.Close()
			r.conn = nil
		}
	} else {
		logx.Debugf("datapoint: %s.%s %s %d",
			strings.Join(rep.Meta(), "."),
			rep.Key(), rep.Value(), rep.When().Unix())
	}
	return
}