Append source auth flag to lotus tracer event

This commit is contained in:
Matija Petrunic 2021-09-21 12:54:07 +02:00
commit 0c390d12f7
3 changed files with 15 additions and 10 deletions

View File

@ -311,6 +311,7 @@ type Pubsub struct {
RemoteTracer string RemoteTracer string
JsonTracerFile string JsonTracerFile string
ElasticSearchTracer string ElasticSearchTracer string
TracerSourceAuth string
} }
type Chainstore struct { type Chainstore struct {

View File

@ -383,7 +383,7 @@ func GossipSub(in GossipIn) (service *pubsub.PubSub, err error) {
} }
transports = append(transports, elasticSearchTransport) transports = append(transports, elasticSearchTransport)
} }
lt := tracer.NewLotusTracer(transports, in.Host.ID()) lt := tracer.NewLotusTracer(transports, in.Host.ID(), in.Cfg.TracerSourceAuth)
// tracer // tracer
if in.Cfg.RemoteTracer != "" { if in.Cfg.RemoteTracer != "" {

View File

@ -11,16 +11,18 @@ import (
var log = logging.Logger("lotus-tracer") var log = logging.Logger("lotus-tracer")
func NewLotusTracer(tt []TracerTransport, pid peer.ID) LotusTracer { func NewLotusTracer(tt []TracerTransport, pid peer.ID, sourceAuth string) LotusTracer {
return &lotusTracer{ return &lotusTracer{
tt: tt, tt: tt,
pid: pid, pid: pid,
sa: sourceAuth,
} }
} }
type lotusTracer struct { type lotusTracer struct {
tt []TracerTransport tt []TracerTransport
pid peer.ID pid peer.ID
sa string
} }
const ( const (
@ -32,6 +34,7 @@ type LotusTraceEvent struct {
PeerID string `json:"peerID,omitempty"` PeerID string `json:"peerID,omitempty"`
Timestamp *int64 `json:"timestamp,omitempty"` Timestamp *int64 `json:"timestamp,omitempty"`
PeerScore TraceEvent_PeerScore `json:"peerScore,omitempty"` PeerScore TraceEvent_PeerScore `json:"peerScore,omitempty"`
SourceAuth string `json:"sourceAuth,omitempty"`
} }
type TraceEvent_PeerScore struct { type TraceEvent_PeerScore struct {
@ -53,6 +56,7 @@ func (lt *lotusTracer) PeerScores(scores map[peer.ID]*pubsub.PeerScoreSnapshot)
Type: *TraceEvent_PEER_SCORES.Enum(), Type: *TraceEvent_PEER_SCORES.Enum(),
PeerID: lt.pid.Pretty(), PeerID: lt.pid.Pretty(),
Timestamp: &now, Timestamp: &now,
SourceAuth: lt.sa,
PeerScore: TraceEvent_PeerScore{PeerID: pid.Pretty(), Score: float32(score.Score)}, PeerScore: TraceEvent_PeerScore{PeerID: pid.Pretty(), Score: float32(score.Score)},
} }