func (t *transport) RoundTrip(req *http.Request) (res *http.Response, err error) {
	start := time.Now()
	rtrip := t.transport
	eng := t.eng
	if rtrip == nil {
		rtrip = http.DefaultTransport
	}
	if tags := RequestTags(req); len(tags) > 0 {
		eng = eng.WithTags(tags...)
	}
	if req.Body == nil {
		req.Body = &nullBody{}
	}
	m := &metrics{}
	req.Body = &requestBody{
		eng:     eng,
		req:     req,
		metrics: m,
		body:    req.Body,
		op:      "write",
	}
	res, err = rtrip.RoundTrip(req)
	req.Body.Close()  
	if err != nil {
		m.observeError(time.Now().Sub(start))
		eng.ReportAt(start, m)
	} else {
		res.Body = &responseBody{
			eng:     eng,
			res:     res,
			metrics: m,
			body:    res.Body,
			op:      "read",
			start:   start,
		}
	}
	return
}
RoundTrip implements http.RoundTripper
package httpstats
import (
	"net/http"
	"time"
	"github.com/segmentio/stats/v4"
)
func NewTransport(t http.RoundTripper) http.RoundTripper {
	return NewTransportWith(stats.DefaultEngine, t)
}
func NewTransportWith(eng *stats.Engine, t http.RoundTripper) http.RoundTripper {
	return &transport{
		transport: t,
		eng:       eng,
	}
}
type transport struct {
	transport http.RoundTripper
	eng       *stats.Engine
}