func logRoutingErrDifferentPeers(ctx context.Context, wanted, got peer.ID, err error) { lm := make(lgbl.DeferredMap) lm["error"] = err lm["wantedPeer"] = func() interface{} { return wanted.Pretty() } lm["gotPeer"] = func() interface{} { return got.Pretty() } log.Event(ctx, "routingError", lm) }
// Unlock releases waiters to a dial attempt. see Lock. // if Unlock(p) is called without calling Lock(p) first, Unlock panics. func (ds *dialsync) Unlock(dst peer.ID) { ds.lock.Lock() wait, found := ds.ongoing[dst] if !found { panic("called dialDone with no ongoing dials to peer: " + dst.Pretty()) } delete(ds.ongoing, dst) // remove ongoing dial close(wait) // release everyone else ds.lock.Unlock() }
// Dial metadata is metadata for dial events func Dial(sys string, lid, rid peer.ID, laddr, raddr ma.Multiaddr) DeferredMap { m := DeferredMap{} m["subsystem"] = sys if lid != "" { m["localPeer"] = func() interface{} { return lid.Pretty() } } if laddr != nil { m["localAddr"] = func() interface{} { return laddr.String() } } if rid != "" { m["remotePeer"] = func() interface{} { return rid.Pretty() } } if raddr != nil { m["remoteAddr"] = func() interface{} { return raddr.String() } } return m }
func peersTotalGauge(id peer.ID) prom.Gauge { return peersTotal.With(prom.Labels{"peer_id": id.Pretty()}) }