// send uses HTTP to send the data to the tracing sidecare for processing.
send uses HTTP to send the data to the tracing sidecare for processing.
// send uses HTTP to send the data to the tracing sidecare for processing .
func (e *Exporter) send(sendBatch []*trace.SpanData) error {
	data, err := json.Marshal(sendBatch)
	if err != nil {
		return err
	}
	req, err := http.NewRequest("POST", e.host, bytes.NewBuffer(data))
	if err != nil {
		return err
	}
	ctx, cancel := context.WithTimeout(req.Context(), e.sendTimeout)
	defer cancel()
	req = req.WithContext(ctx)
	ch := make(chan error)
	go func() {
		resp, err := e.client.Do(req)
		if err != nil {
			ch <- err
			return
		}
		defer resp.Body.Close()
		if resp.StatusCode != http.StatusNoContent {
			data, err := ioutil.ReadAll(resp.Body)
			if err != nil {
				ch <- fmt.Errorf("error on call : status[%s]", resp.Status)
				return
			}
			ch <- fmt.Errorf("error on call : status[%s] : %s", resp.Status, string(data))
			return
		}
		ch <- nil
	}()
	return <-ch
}
func ( e * Exporter ) send ( sendBatch [ ] * trace . SpanData ) error { data , err := json . Marshal ( sendBatch ) if err != nil { return err } req , err := http . NewRequest ( " " , e . host , bytes . NewBuffer ( data ) ) if err != nil { return err } ctx , cancel := context . WithTimeout ( req . Context ( ) , e . sendTimeout ) defer cancel ( ) req = req . WithContext ( ctx ) ch := make ( chan error ) go func ( ) { resp , err := e . client . Do ( req ) if err != nil { ch <- err return } defer resp . Body . Close ( ) if resp . StatusCode != http . StatusNoContent { data , err := ioutil . ReadAll ( resp . Body ) if err != nil { ch <- fmt . Errorf ( " " , resp . Status ) return } ch <- fmt . Errorf ( " " , resp . Status , string ( data ) ) return } ch <- nil } ( ) return <- ch }
send uses HTTP to send the data to the tracing sidecare for processing.
send uses HTTP to send the data to the tracing sidecare for processing .