anacrolix / torrent

Full-featured BitTorrent client package and utilities
Mozilla Public License 2.0
5.39k stars 615 forks source link

Error tracking #913

Closed DannyZB closed 2 months ago

DannyZB commented 3 months ago

Looking at the library, I could not find standardized ways to track or report errors. Tracker errors, connection errors, announce status, peer errors etc'.

What are the mechanisms in place? Which data is accessible to track the health of swarms, connections, trackers?

This is a pretty significant feature that doesn't seem visible or even implemented.

I can see the torrent object has multiple useful properties, but they are unexported, like func (t *Torrent) writeStatus(w io.Writer)

Would I need to fork this repo and expose these properties? (Like trackerAnnouncers)

Note: Another candidate may be var vars = expvar.NewMap("tracker/http") from http/tracker?

anacrolix commented 3 months ago

Looking at the library, I could not find standardized ways to track or report errors. Tracker errors, connection errors, announce status, peer errors etc'.

There's no standard way to expose those errors. There is a related issue about it that I can't find right now.

What are the mechanisms in place? Which data is accessible to track the health of swarms, connections, trackers?

This is a pretty significant feature that doesn't seem visible or even implemented.

I can see the torrent object has multiple useful properties, but they are unexported, like func (t *Torrent) writeStatus(w io.Writer)

Would I need to fork this repo and expose these properties? (Like trackerAnnouncers)

Note: Another candidate may be var vars = expvar.NewMap("tracker/http") from http/tracker?

You are welcome to expose anything you require for your usage, the only reason I haven't done it myself is I don't want to invent requirements that I don't have myself. If I know that the interfaces exposed are in the form people are depending on I will be receptive to those PRs. I do use the Client.WriteStatus endpoint to debug some of the live/downstream services based on anacrolix/torrent. A handful of other interfaces exist for some client implementations, like the event pubsub stuff, and various queries available on pieces and torrents.

It will be worthwhile to run any code that end up exporting with the race detector enabled, it's very easy and common to introduce race conditions when doing that.