Change peer score event type to avoid exceeding elastisearch field limit
This commit is contained in:
parent
a91ffa60d6
commit
7d0aefacbb
@ -31,11 +31,12 @@ type LotusTraceEvent struct {
|
|||||||
Type pubsub_pb.TraceEvent_Type `json:"type,omitempty"`
|
Type pubsub_pb.TraceEvent_Type `json:"type,omitempty"`
|
||||||
PeerID string `json:"peerID,omitempty"`
|
PeerID string `json:"peerID,omitempty"`
|
||||||
Timestamp *int64 `json:"timestamp,omitempty"`
|
Timestamp *int64 `json:"timestamp,omitempty"`
|
||||||
PeerScores *TraceEvent_PeerScores `json:"peerScores,omitempty"`
|
PeerScores []TraceEvent_PeerScore `json:"peerScores,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TraceEvent_PeerScores struct {
|
type TraceEvent_PeerScore struct {
|
||||||
Scores map[peer.ID]*pubsub.PeerScoreSnapshot `json:"scores,omitempty"`
|
PeerID string `json:"peerID"`
|
||||||
|
Score float32 `json:"score"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type LotusTracer interface {
|
type LotusTracer interface {
|
||||||
@ -46,14 +47,17 @@ type LotusTracer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (lt *lotusTracer) PeerScores(scores map[peer.ID]*pubsub.PeerScoreSnapshot) {
|
func (lt *lotusTracer) PeerScores(scores map[peer.ID]*pubsub.PeerScoreSnapshot) {
|
||||||
|
var peerScores []TraceEvent_PeerScore
|
||||||
|
for pid, score := range scores {
|
||||||
|
peerScores = append(peerScores, TraceEvent_PeerScore{PeerID: pid.Pretty(), Score: float32(score.Score)})
|
||||||
|
}
|
||||||
|
|
||||||
now := time.Now().UnixNano()
|
now := time.Now().UnixNano()
|
||||||
evt := &LotusTraceEvent{
|
evt := &LotusTraceEvent{
|
||||||
Type: *TraceEvent_PEER_SCORES.Enum(),
|
Type: *TraceEvent_PEER_SCORES.Enum(),
|
||||||
PeerID: string(lt.pid),
|
PeerID: string(lt.pid),
|
||||||
Timestamp: &now,
|
Timestamp: &now,
|
||||||
PeerScores: &TraceEvent_PeerScores{
|
PeerScores: peerScores,
|
||||||
Scores: scores,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lt.TraceLotusEvent(evt)
|
lt.TraceLotusEvent(evt)
|
||||||
|
Loading…
Reference in New Issue
Block a user