satellite/contact: emit evenkit events in case of node checkin
Change-Id: I2da4b3055b410e476d63cc6addf982a130dba611
This commit is contained in:
parent
5c2b111347
commit
97679a39ff
@ -4,11 +4,16 @@
|
||||
package contact
|
||||
|
||||
import (
|
||||
"github.com/jtolio/eventkit"
|
||||
"github.com/spacemonkeygo/monkit/v3"
|
||||
"github.com/zeebo/errs"
|
||||
)
|
||||
|
||||
var (
|
||||
// Error is the default error class for contact package.
|
||||
var Error = errs.Class("contact")
|
||||
Error = errs.Class("contact")
|
||||
|
||||
var mon = monkit.Package()
|
||||
mon = monkit.Package()
|
||||
|
||||
ek = eventkit.Package()
|
||||
)
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/jtolio/eventkit"
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
|
||||
@ -15,6 +16,7 @@ import (
|
||||
"storj.io/common/pb"
|
||||
"storj.io/common/rpc/rpcstatus"
|
||||
"storj.io/common/storj"
|
||||
"storj.io/drpc/drpcctx"
|
||||
"storj.io/storj/private/nodeoperator"
|
||||
"storj.io/storj/satellite/overlay"
|
||||
)
|
||||
@ -114,6 +116,8 @@ func (endpoint *Endpoint) CheckIn(ctx context.Context, req *pb.CheckInRequest) (
|
||||
Version: req.Version,
|
||||
}
|
||||
|
||||
endpoint.emitEvenkitEvent(ctx, req, pingNodeSuccess, pingNodeSuccessQUIC, nodeInfo)
|
||||
|
||||
err = endpoint.service.overlay.UpdateCheckIn(ctx, nodeInfo, time.Now().UTC())
|
||||
if err != nil {
|
||||
endpoint.log.Info("failed to update check in", zap.String("node address", req.Address), zap.Stringer("Node ID", nodeID), zap.Error(err))
|
||||
@ -128,6 +132,32 @@ func (endpoint *Endpoint) CheckIn(ctx context.Context, req *pb.CheckInRequest) (
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (endpoint *Endpoint) emitEvenkitEvent(ctx context.Context, req *pb.CheckInRequest, pingNodeTCPSuccess bool, pingNodeQUICSuccess bool, nodeInfo overlay.NodeCheckInInfo) {
|
||||
var sourceAddr string
|
||||
transport, found := drpcctx.Transport(ctx)
|
||||
if found {
|
||||
if conn, ok := transport.(net.Conn); ok {
|
||||
a := conn.RemoteAddr()
|
||||
if a != nil {
|
||||
sourceAddr = a.String()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ek.Event("checkin",
|
||||
eventkit.String("id", nodeInfo.NodeID.String()),
|
||||
eventkit.String("addr", req.Address),
|
||||
eventkit.String("resolved-addr", nodeInfo.LastIPPort),
|
||||
eventkit.String("source-addr", sourceAddr),
|
||||
eventkit.Timestamp("build-time", nodeInfo.Version.Timestamp),
|
||||
eventkit.String("version", nodeInfo.Version.Version),
|
||||
eventkit.String("country", nodeInfo.CountryCode.String()),
|
||||
eventkit.Int64("free-disk", nodeInfo.Capacity.FreeDisk),
|
||||
eventkit.Bool("ping-tpc-success", pingNodeTCPSuccess),
|
||||
eventkit.Bool("ping-quic-success", pingNodeQUICSuccess),
|
||||
)
|
||||
}
|
||||
|
||||
// GetTime returns current timestamp.
|
||||
func (endpoint *Endpoint) GetTime(ctx context.Context, req *pb.GetTimeRequest) (_ *pb.GetTimeResponse, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
Loading…
Reference in New Issue
Block a user