Closed MashinaMashina closed 1 month ago
ctx in TrackConnection method allows add your logic in custom implementation. Example:
req, err := http.NewRequestWithContext(context.WithValue(context.Background(), "do_not_track", "1"), http.MethodGet, "https://www.topps.com/", nil)
...
func (bt *Tracker) TrackConnection(ctx context.Context, conn net.Conn) net.Conn {
if ctx.Value("do_not_track") != nil {
return conn
}
return newTrackedConn(conn, bt)
}
(In example, I need to measure traffic by individual routes. With ctx I store route, and in my tracker implementation i will write to different trackers)
@MashinaMashina thank you for your contribution
Not everyone needs a tracker. If you needs, enable using option: