mirror of
https://github.com/livekit/livekit.git
synced 2026-10-22 12:22:28 +00:00
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:
1 parent
bce3a9b10a
commit
d3ca4a37a8
4 files changed
+75
-2
No files matched your search
@@ -97,6 +97,7 @@ func (t *MediaTrackSubscriptions) IsSubscriber(subID livekit.ParticipantID) bool
|
||||
|
||||
// AddSubscriber subscribes sub to current mediaTrack
|
||||
func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, codec webrtc.RTPCodecCapability, wr WrappedReceiver) (*sfu.DownTrack, error) {
|
||||
trackID := t.params.MediaTrack.ID()
|
||||
subscriberID := sub.ID()
|
||||
|
||||
t.subscribedTracksMu.Lock()
|
||||
@@ -126,7 +127,7 @@ func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, code
|
||||
t.params.BufferFactory,
|
||||
subscriberID,
|
||||
t.params.ReceiverConfig.PacketBufferSize,
|
||||
LoggerWithParticipant(t.params.Logger, sub.Identity(), sub.ID()),
|
||||
LoggerWithTrack(sub.GetLogger(), trackID),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -190,7 +191,6 @@ func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, code
|
||||
go t.sendDownTrackBindingReports(sub)
|
||||
})
|
||||
|
||||
trackID := t.params.MediaTrack.ID()
|
||||
downTrack.OnStatsUpdate(func(_ *sfu.DownTrack, stat *livekit.AnalyticsStat) {
|
||||
t.params.Telemetry.TrackStats(livekit.StreamType_DOWNSTREAM, subscriberID, trackID, stat)
|
||||
})
|
||||
|
||||
@@ -223,6 +223,10 @@ func NewParticipant(params ParticipantParams, perms *livekit.ParticipantPermissi
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) GetLogger() logger.Logger {
|
||||
return p.params.Logger
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) ID() livekit.ParticipantID {
|
||||
return p.params.SID
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/livekit/protocol/auth"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/pion/webrtc/v3"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/routing"
|
||||
@@ -84,6 +85,8 @@ type Participant interface {
|
||||
type LocalParticipant interface {
|
||||
Participant
|
||||
|
||||
GetLogger() logger.Logger
|
||||
|
||||
ProtocolVersion() ProtocolVersion
|
||||
|
||||
ConnectedAt() time.Time
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
"github.com/livekit/protocol/auth"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
webrtc "github.com/pion/webrtc/v3"
|
||||
)
|
||||
|
||||
@@ -148,6 +149,16 @@ type FakeLocalParticipant struct {
|
||||
getConnectionQualityReturnsOnCall map[int]struct {
|
||||
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
|
||||
getPublishedTrackMutex sync.RWMutex
|
||||
getPublishedTrackArgsForCall []struct {
|
||||
@@ -1303,6 +1314,59 @@ func (fake *FakeLocalParticipant) GetConnectionQualityReturnsOnCall(i int, resul
|
||||
}{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 {
|
||||
fake.getPublishedTrackMutex.Lock()
|
||||
ret, specificReturn := fake.getPublishedTrackReturnsOnCall[len(fake.getPublishedTrackArgsForCall)]
|
||||
@@ -3747,6 +3811,8 @@ func (fake *FakeLocalParticipant) Invocations() map[string][][]interface{} {
|
||||
defer fake.getAudioLevelMutex.RUnlock()
|
||||
fake.getConnectionQualityMutex.RLock()
|
||||
defer fake.getConnectionQualityMutex.RUnlock()
|
||||
fake.getLoggerMutex.RLock()
|
||||
defer fake.getLoggerMutex.RUnlock()
|
||||
fake.getPublishedTrackMutex.RLock()
|
||||
defer fake.getPublishedTrackMutex.RUnlock()
|
||||
fake.getPublishedTracksMutex.RLock()
|
||||
|
||||
Reference in new issue
Block a user