telemetry interfaces (#210)

* telemetry interfaces

* move AddUptrack under stats

* regenerate

* a space

* consistency

* fix test
This commit is contained in:
David Colburn
2021-11-24 17:58:04 -08:00
committed by GitHub
parent f4c96449ae
commit 991c334d2d
14 changed files with 152 additions and 98 deletions
+6 -5
View File
@@ -1,6 +1,7 @@
package rtc
import (
"context"
"errors"
"sync"
"sync/atomic"
@@ -74,7 +75,7 @@ type MediaTrackParams struct {
BufferFactory *buffer.Factory
ReceiverConfig ReceiverConfig
AudioConfig config.AudioConfig
Telemetry *telemetry.TelemetryService
Telemetry telemetry.TelemetryService
Logger logger.Logger
}
@@ -249,7 +250,7 @@ func (t *MediaTrack) AddSubscriber(sub types.Participant) error {
delete(t.subscribedTracks, sub.ID())
t.lock.Unlock()
t.params.Telemetry.TrackUnsubscribed(sub.ID(), t.ToProto())
t.params.Telemetry.TrackUnsubscribed(context.Background(), sub.ID(), t.ToProto())
// ignore if the subscribing sub is not connected
if sub.SubscriberPC().ConnectionState() == webrtc.PeerConnectionStateClosed {
@@ -299,7 +300,7 @@ func (t *MediaTrack) AddSubscriber(sub types.Participant) error {
sub.Negotiate()
}()
t.params.Telemetry.TrackSubscribed(sub.ID(), t.ToProto())
t.params.Telemetry.TrackSubscribed(context.Background(), sub.ID(), t.ToProto())
return nil
}
@@ -380,12 +381,12 @@ func (t *MediaTrack) AddReceiver(receiver *webrtc.RTPReceiver, track *webrtc.Tra
onclose := t.onClose
t.lock.Unlock()
t.RemoveAllSubscribers()
t.params.Telemetry.TrackUnpublished(t.params.ParticipantID, t.ToProto(), uint32(track.SSRC()))
t.params.Telemetry.TrackUnpublished(context.Background(), t.params.ParticipantID, t.ToProto(), uint32(track.SSRC()))
if onclose != nil {
onclose()
}
})
t.params.Telemetry.TrackPublished(t.params.ParticipantID, t.ToProto())
t.params.Telemetry.TrackPublished(context.Background(), t.params.ParticipantID, t.ToProto())
if t.Kind() == livekit.TrackType_AUDIO {
t.buffer = buff
}
+1 -1
View File
@@ -39,7 +39,7 @@ type ParticipantParams struct {
Sink routing.MessageSink
AudioConfig config.AudioConfig
ProtocolVersion types.ProtocolVersion
Telemetry *telemetry.TelemetryService
Telemetry telemetry.TelemetryService
ThrottleConfig config.PLIThrottleConfig
EnabledCodecs []*livekit.Codec
Hidden bool
+2 -2
View File
@@ -34,7 +34,7 @@ type Room struct {
config WebRTCConfig
audioConfig *config.AudioConfig
telemetry *telemetry.TelemetryService
telemetry telemetry.TelemetryService
// map of identity -> Participant
participants map[string]types.Participant
@@ -57,7 +57,7 @@ type ParticipantOptions struct {
AutoSubscribe bool
}
func NewRoom(room *livekit.Room, config WebRTCConfig, audioConfig *config.AudioConfig, telemetry *telemetry.TelemetryService) *Room {
func NewRoom(room *livekit.Room, config WebRTCConfig, audioConfig *config.AudioConfig, telemetry telemetry.TelemetryService) *Room {
r := &Room{
Room: proto.Clone(room).(*livekit.Room),
Logger: logger.Logger(logger.GetLogger().WithValues("room", room.Name)),
+1 -1
View File
@@ -552,7 +552,7 @@ func newRoomWithParticipants(t *testing.T, opts testRoomOpts) *rtc.Room {
UpdateInterval: audioUpdateInterval,
SmoothIntervals: opts.audioSmoothIntervals,
},
telemetry.NewTelemetryService(nil),
telemetry.NewTelemetryService(nil, nil),
)
for i := 0; i < opts.num+opts.numHidden; i++ {
identity := fmt.Sprintf("p%d", i)
+1 -1
View File
@@ -45,7 +45,7 @@ type TransportParams struct {
ParticipantIdentity string
Target livekit.SignalTarget
Config *WebRTCConfig
Telemetry *telemetry.TelemetryService
Telemetry telemetry.TelemetryService
EnabledCodecs []*livekit.Codec
Logger logger.Logger
}