mirror of
https://github.com/libp2p/go-libp2p.git
synced 2026-04-23 00:27:05 +08:00
holepunch: add metrics (#2246)
* holepunch: add metrics * don't track addresses * add cancelled and no_suitable_address state * separate holepunch dashbords by transport * fix dashboard fields * add instance filter to dashboard * initialise metrics labels with 0 * fix panel names in dashboard Co-authored-by: Marten Seemann <martenseemann@gmail.com> --------- Co-authored-by: Marten Seemann <martenseemann@gmail.com>
This commit is contained in:
@@ -251,6 +251,12 @@ func NewHost(n network.Network, opts *HostOpts) (*BasicHost, error) {
|
||||
}
|
||||
|
||||
if opts.EnableHolePunching {
|
||||
if opts.EnableMetrics {
|
||||
hpOpts := []holepunch.Option{
|
||||
holepunch.WithMetricsTracer(holepunch.NewMetricsTracer(holepunch.WithRegisterer(opts.PrometheusRegisterer)))}
|
||||
opts.HolePunchingOptions = append(hpOpts, opts.HolePunchingOptions...)
|
||||
|
||||
}
|
||||
h.hps, err = holepunch.NewService(h, h.ids, opts.HolePunchingOptions...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create hole punch service: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user