Proper context for down track logger (#416)
It was having two participants (both publisher and subscriber). Fix it by getting logger from susbcriber and adding track context.
This commit is contained in:
@@ -97,6 +97,7 @@ func (t *MediaTrackSubscriptions) IsSubscriber(subID livekit.ParticipantID) bool
|
|||||||
|
|
||||||
// AddSubscriber subscribes sub to current mediaTrack
|
// AddSubscriber subscribes sub to current mediaTrack
|
||||||
func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, codec webrtc.RTPCodecCapability, wr WrappedReceiver) (*sfu.DownTrack, error) {
|
func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, codec webrtc.RTPCodecCapability, wr WrappedReceiver) (*sfu.DownTrack, error) {
|
||||||
|
trackID := t.params.MediaTrack.ID()
|
||||||
subscriberID := sub.ID()
|
subscriberID := sub.ID()
|
||||||
|
|
||||||
t.subscribedTracksMu.Lock()
|
t.subscribedTracksMu.Lock()
|
||||||
@@ -126,7 +127,7 @@ func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, code
|
|||||||
t.params.BufferFactory,
|
t.params.BufferFactory,
|
||||||
subscriberID,
|
subscriberID,
|
||||||
t.params.ReceiverConfig.PacketBufferSize,
|
t.params.ReceiverConfig.PacketBufferSize,
|
||||||
LoggerWithParticipant(t.params.Logger, sub.Identity(), sub.ID()),
|
LoggerWithTrack(sub.GetLogger(), trackID),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -190,7 +191,6 @@ func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, code
|
|||||||
go t.sendDownTrackBindingReports(sub)
|
go t.sendDownTrackBindingReports(sub)
|
||||||
})
|
})
|
||||||
|
|
||||||
trackID := t.params.MediaTrack.ID()
|
|
||||||
downTrack.OnStatsUpdate(func(_ *sfu.DownTrack, stat *livekit.AnalyticsStat) {
|
downTrack.OnStatsUpdate(func(_ *sfu.DownTrack, stat *livekit.AnalyticsStat) {
|
||||||
t.params.Telemetry.TrackStats(livekit.StreamType_DOWNSTREAM, subscriberID, trackID, stat)
|
t.params.Telemetry.TrackStats(livekit.StreamType_DOWNSTREAM, subscriberID, trackID, stat)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -223,6 +223,10 @@ func NewParticipant(params ParticipantParams, perms *livekit.ParticipantPermissi
|
|||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *ParticipantImpl) GetLogger() logger.Logger {
|
||||||
|
return p.params.Logger
|
||||||
|
}
|
||||||
|
|
||||||
func (p *ParticipantImpl) ID() livekit.ParticipantID {
|
func (p *ParticipantImpl) ID() livekit.ParticipantID {
|
||||||
return p.params.SID
|
return p.params.SID
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/livekit/protocol/auth"
|
"github.com/livekit/protocol/auth"
|
||||||
"github.com/livekit/protocol/livekit"
|
"github.com/livekit/protocol/livekit"
|
||||||
|
"github.com/livekit/protocol/logger"
|
||||||
"github.com/pion/webrtc/v3"
|
"github.com/pion/webrtc/v3"
|
||||||
|
|
||||||
"github.com/livekit/livekit-server/pkg/routing"
|
"github.com/livekit/livekit-server/pkg/routing"
|
||||||
@@ -84,6 +85,8 @@ type Participant interface {
|
|||||||
type LocalParticipant interface {
|
type LocalParticipant interface {
|
||||||
Participant
|
Participant
|
||||||
|
|
||||||
|
GetLogger() logger.Logger
|
||||||
|
|
||||||
ProtocolVersion() ProtocolVersion
|
ProtocolVersion() ProtocolVersion
|
||||||
|
|
||||||
ConnectedAt() time.Time
|
ConnectedAt() time.Time
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||||
"github.com/livekit/protocol/auth"
|
"github.com/livekit/protocol/auth"
|
||||||
"github.com/livekit/protocol/livekit"
|
"github.com/livekit/protocol/livekit"
|
||||||
|
"github.com/livekit/protocol/logger"
|
||||||
webrtc "github.com/pion/webrtc/v3"
|
webrtc "github.com/pion/webrtc/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -148,6 +149,16 @@ type FakeLocalParticipant struct {
|
|||||||
getConnectionQualityReturnsOnCall map[int]struct {
|
getConnectionQualityReturnsOnCall map[int]struct {
|
||||||
result1 *livekit.ConnectionQualityInfo
|
result1 *livekit.ConnectionQualityInfo
|
||||||
}
|
}
|
||||||
|
GetLoggerStub func() logger.Logger
|
||||||
|
getLoggerMutex sync.RWMutex
|
||||||
|
getLoggerArgsForCall []struct {
|
||||||
|
}
|
||||||
|
getLoggerReturns struct {
|
||||||
|
result1 logger.Logger
|
||||||
|
}
|
||||||
|
getLoggerReturnsOnCall map[int]struct {
|
||||||
|
result1 logger.Logger
|
||||||
|
}
|
||||||
GetPublishedTrackStub func(livekit.TrackID) types.MediaTrack
|
GetPublishedTrackStub func(livekit.TrackID) types.MediaTrack
|
||||||
getPublishedTrackMutex sync.RWMutex
|
getPublishedTrackMutex sync.RWMutex
|
||||||
getPublishedTrackArgsForCall []struct {
|
getPublishedTrackArgsForCall []struct {
|
||||||
@@ -1303,6 +1314,59 @@ func (fake *FakeLocalParticipant) GetConnectionQualityReturnsOnCall(i int, resul
|
|||||||
}{result1}
|
}{result1}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (fake *FakeLocalParticipant) GetLogger() logger.Logger {
|
||||||
|
fake.getLoggerMutex.Lock()
|
||||||
|
ret, specificReturn := fake.getLoggerReturnsOnCall[len(fake.getLoggerArgsForCall)]
|
||||||
|
fake.getLoggerArgsForCall = append(fake.getLoggerArgsForCall, struct {
|
||||||
|
}{})
|
||||||
|
stub := fake.GetLoggerStub
|
||||||
|
fakeReturns := fake.getLoggerReturns
|
||||||
|
fake.recordInvocation("GetLogger", []interface{}{})
|
||||||
|
fake.getLoggerMutex.Unlock()
|
||||||
|
if stub != nil {
|
||||||
|
return stub()
|
||||||
|
}
|
||||||
|
if specificReturn {
|
||||||
|
return ret.result1
|
||||||
|
}
|
||||||
|
return fakeReturns.result1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fake *FakeLocalParticipant) GetLoggerCallCount() int {
|
||||||
|
fake.getLoggerMutex.RLock()
|
||||||
|
defer fake.getLoggerMutex.RUnlock()
|
||||||
|
return len(fake.getLoggerArgsForCall)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fake *FakeLocalParticipant) GetLoggerCalls(stub func() logger.Logger) {
|
||||||
|
fake.getLoggerMutex.Lock()
|
||||||
|
defer fake.getLoggerMutex.Unlock()
|
||||||
|
fake.GetLoggerStub = stub
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fake *FakeLocalParticipant) GetLoggerReturns(result1 logger.Logger) {
|
||||||
|
fake.getLoggerMutex.Lock()
|
||||||
|
defer fake.getLoggerMutex.Unlock()
|
||||||
|
fake.GetLoggerStub = nil
|
||||||
|
fake.getLoggerReturns = struct {
|
||||||
|
result1 logger.Logger
|
||||||
|
}{result1}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fake *FakeLocalParticipant) GetLoggerReturnsOnCall(i int, result1 logger.Logger) {
|
||||||
|
fake.getLoggerMutex.Lock()
|
||||||
|
defer fake.getLoggerMutex.Unlock()
|
||||||
|
fake.GetLoggerStub = nil
|
||||||
|
if fake.getLoggerReturnsOnCall == nil {
|
||||||
|
fake.getLoggerReturnsOnCall = make(map[int]struct {
|
||||||
|
result1 logger.Logger
|
||||||
|
})
|
||||||
|
}
|
||||||
|
fake.getLoggerReturnsOnCall[i] = struct {
|
||||||
|
result1 logger.Logger
|
||||||
|
}{result1}
|
||||||
|
}
|
||||||
|
|
||||||
func (fake *FakeLocalParticipant) GetPublishedTrack(arg1 livekit.TrackID) types.MediaTrack {
|
func (fake *FakeLocalParticipant) GetPublishedTrack(arg1 livekit.TrackID) types.MediaTrack {
|
||||||
fake.getPublishedTrackMutex.Lock()
|
fake.getPublishedTrackMutex.Lock()
|
||||||
ret, specificReturn := fake.getPublishedTrackReturnsOnCall[len(fake.getPublishedTrackArgsForCall)]
|
ret, specificReturn := fake.getPublishedTrackReturnsOnCall[len(fake.getPublishedTrackArgsForCall)]
|
||||||
@@ -3747,6 +3811,8 @@ func (fake *FakeLocalParticipant) Invocations() map[string][][]interface{} {
|
|||||||
defer fake.getAudioLevelMutex.RUnlock()
|
defer fake.getAudioLevelMutex.RUnlock()
|
||||||
fake.getConnectionQualityMutex.RLock()
|
fake.getConnectionQualityMutex.RLock()
|
||||||
defer fake.getConnectionQualityMutex.RUnlock()
|
defer fake.getConnectionQualityMutex.RUnlock()
|
||||||
|
fake.getLoggerMutex.RLock()
|
||||||
|
defer fake.getLoggerMutex.RUnlock()
|
||||||
fake.getPublishedTrackMutex.RLock()
|
fake.getPublishedTrackMutex.RLock()
|
||||||
defer fake.getPublishedTrackMutex.RUnlock()
|
defer fake.getPublishedTrackMutex.RUnlock()
|
||||||
fake.getPublishedTracksMutex.RLock()
|
fake.getPublishedTracksMutex.RLock()
|
||||||
|
|||||||
Reference in New Issue
Block a user