func (m *MetricsClient) print() { var bf = &bytes.Buffer{} shot := map[string]interface{}{ "endpoint": m.endpoint, "service": m.serviceName, "data": m.r, } json.NewEncoder(bf).Encode(shot) log.Info("[metrics] " + bf.String()) }
func (m *MetricsClient) report() { var bf = &bytes.Buffer{} shot := map[string]interface{}{ "endpoint": m.endpoint, "service": m.serviceName, "data": m.d, } json.NewEncoder(bf).Encode(shot) log.Info("[metrics] QPS " + bf.String()) results := snapShotMetricsSts(m.d) m.d.Each(func(k string, _ interface{}) { c := metrics.GetOrRegisterCounter(k, m.d) c.Clear() }) // TODO // http should be async // file should be async-write, log should be refact bf.Reset() json.NewEncoder(bf).Encode(results) m.transport.Send(m.centerAddr, bf.Bytes()) }
func (c *httpClient) Send(uri string, data []byte) (err error) { log.Info(string(data)) req, err := http.NewRequest("POST", uri, bytes.NewReader(data)) if err != nil { log.Warnf("new http request err: %v", err) return err } resp, err := c.cli.Do(req) if err != nil { log.Warnf("do http request err: %v", err) return err } defer resp.Body.Close() respData, err := ioutil.ReadAll(resp.Body) if err != nil { log.Warnf("do http request err: %v", err) return err } // TODO check _ = respData return }
func (l logger) Printf(format string, a ...interface{}) { log.Info("[zk] ", fmt.Sprintf(format, a...)) }
func (l *kafkaLogger) Println(v ...interface{}) { args := []interface{}{"[sarama] "} args = append(args, v...) log.Info(args...) }
func (l *kafkaLogger) Printf(format string, v ...interface{}) { log.Info("[sarama] ", fmt.Sprintf(format, v...)) }