Send peerID peer score as separate events to enable usage of kibana runtime fields
This commit is contained in:
parent
082f70757c
commit
d65d9aa6e0
@ -31,7 +31,7 @@ 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_PeerScore `json:"peerScores,omitempty"`
|
PeerScore TraceEvent_PeerScore `json:"peerScore,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TraceEvent_PeerScore struct {
|
type TraceEvent_PeerScore struct {
|
||||||
@ -47,20 +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()
|
||||||
|
for pid, score := range scores {
|
||||||
evt := &LotusTraceEvent{
|
evt := &LotusTraceEvent{
|
||||||
Type: *TraceEvent_PEER_SCORES.Enum(),
|
Type: *TraceEvent_PEER_SCORES.Enum(),
|
||||||
PeerID: string(lt.pid),
|
PeerID: lt.pid.Pretty(),
|
||||||
Timestamp: &now,
|
Timestamp: &now,
|
||||||
PeerScores: peerScores,
|
PeerScore: TraceEvent_PeerScore{PeerID: pid.Pretty(), Score: float32(score.Score)},
|
||||||
}
|
}
|
||||||
|
|
||||||
lt.TraceLotusEvent(evt)
|
lt.TraceLotusEvent(evt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lt *lotusTracer) TraceLotusEvent(evt *LotusTraceEvent) {
|
func (lt *lotusTracer) TraceLotusEvent(evt *LotusTraceEvent) {
|
||||||
|
Loading…
Reference in New Issue
Block a user