Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MM-60561] RTC client metrics #874

Merged
merged 5 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/mattermost/mattermost-plugin-calls/server/public v0.0.3
github.com/mattermost/mattermost/server/public v0.1.5-0.20240613070149-4b0ae20ef7b4
github.com/mattermost/morph v1.1.0
github.com/mattermost/rtcd v0.17.2-0.20241001213445-b9fc45957c98
github.com/mattermost/rtcd v0.17.2-0.20241009214839-a44d499cefcc
github.com/mattermost/squirrel v0.2.0
github.com/pkg/errors v0.9.1
github.com/rudderlabs/analytics-go v3.3.3+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ github.com/mattermost/mattermost/server/public v0.1.5-0.20240613070149-4b0ae20ef
github.com/mattermost/mattermost/server/public v0.1.5-0.20240613070149-4b0ae20ef7b4/go.mod h1:PDPb/iqzJJ5ZvK/m70oDF55AXN/cOvVFj96Yu4e6j+Q=
github.com/mattermost/morph v1.1.0 h1:Q9vrJbeM3s2jfweGheq12EFIzdNp9a/6IovcbvOQ6Cw=
github.com/mattermost/morph v1.1.0/go.mod h1:gD+EaqX2UMyyuzmF4PFh4r33XneQ8Nzi+0E8nXjMa3A=
github.com/mattermost/rtcd v0.17.2-0.20241001213445-b9fc45957c98 h1:1KuAWd42Bj8sljLQd7r1iYjPWIvYNorny7bEQAZUJCk=
github.com/mattermost/rtcd v0.17.2-0.20241001213445-b9fc45957c98/go.mod h1:FVyFLa+7dWImCZ+0g9xoc/1fMRKMuXs6yAZP1mDKBIg=
github.com/mattermost/rtcd v0.17.2-0.20241009214839-a44d499cefcc h1:KTdzXsjcrnawYH2uNwLW8WVe0vyYmuC8ckpR83Cj7Sg=
github.com/mattermost/rtcd v0.17.2-0.20241009214839-a44d499cefcc/go.mod h1:FVyFLa+7dWImCZ+0g9xoc/1fMRKMuXs6yAZP1mDKBIg=
github.com/mattermost/squirrel v0.2.0 h1:8ZWeyf+MWQ2cL7hu9REZgLtz2IJi51qqZEovI3T3TT8=
github.com/mattermost/squirrel v0.2.0/go.mod h1:NPPtk+CdpWre4GxMGoOpzEVFVc0ZoEFyJBZGCtn9nSU=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
Expand Down
31 changes: 31 additions & 0 deletions lt/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,33 @@ func (u *User) getCallsConfig() (map[string]any, error) {
return config, nil
}

func (u *User) handleTrack(ctx any) error {
m, ok := ctx.(map[string]any)
if !ok || m == nil {
return fmt.Errorf("failed to convert map")
}

track, ok := m["track"].(*webrtc.TrackRemote)
if !ok || track == nil {
return fmt.Errorf("failed to convert track")
}

// We don't currently do anything with the packets but we should still read
// them to properly calculate client stats.
buf := make([]byte, receiveMTU)
for {
_, _, readErr := track.Read(buf)
if readErr != nil {
if !errors.Is(readErr, io.EOF) {
u.log.Error("failed to read RTP packet for track",
slog.String("err", readErr.Error()),
slog.String("trackID", track.ID()))
}
return nil
}
}
}

func (u *User) Connect(stopCh chan struct{}) error {
u.log.Debug("connecting user")

Expand Down Expand Up @@ -609,10 +636,14 @@ func (u *User) Connect(stopCh chan struct{}) error {
ChannelID: u.cfg.ChannelID,
EnableAV1: enableAV1,
EnableDCSignaling: enableDCSignaling,
EnableRTCMonitor: true,
}, client.WithLogger(u.log))
if err != nil {
return fmt.Errorf("failed to create calls client: %w", err)
}
if err := callsClient.On(client.RTCTrackEvent, u.handleTrack); err != nil {
return fmt.Errorf("failed to add track handler: %w", err)
}

u.callsClient = callsClient

Expand Down
2 changes: 1 addition & 1 deletion lt/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/aws/aws-sdk-go v1.50.3
github.com/hajimehoshi/go-mp3 v0.3.4
github.com/mattermost/mattermost/server/public v0.0.12
github.com/mattermost/rtcd v0.17.2-0.20241001213445-b9fc45957c98
github.com/mattermost/rtcd v0.17.2-0.20241009214839-a44d499cefcc
github.com/pion/rtp v1.8.6
github.com/pion/webrtc/v3 v3.2.41
gopkg.in/hraban/opus.v2 v2.0.0-20230925203106-0188a62cb302
Expand Down
4 changes: 2 additions & 2 deletions lt/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ github.com/mattermost/logr/v2 v2.0.21 h1:CMHsP+nrbRlEC4g7BwOk1GAnMtHkniFhlSQPXy5
github.com/mattermost/logr/v2 v2.0.21/go.mod h1:kZkB/zqKL9e+RY5gB3vGpsyenC+TpuiOenjMkvJJbzc=
github.com/mattermost/mattermost/server/public v0.0.12 h1:iunc9q4/XkArOrndEUn73uFw6v9TOEXEtp6Nm6Iv218=
github.com/mattermost/mattermost/server/public v0.0.12/go.mod h1:Bk+atJcELCIk9Yeq5FoqTr+gra9704+X4amrlwlTgSc=
github.com/mattermost/rtcd v0.17.2-0.20241001213445-b9fc45957c98 h1:1KuAWd42Bj8sljLQd7r1iYjPWIvYNorny7bEQAZUJCk=
github.com/mattermost/rtcd v0.17.2-0.20241001213445-b9fc45957c98/go.mod h1:FVyFLa+7dWImCZ+0g9xoc/1fMRKMuXs6yAZP1mDKBIg=
github.com/mattermost/rtcd v0.17.2-0.20241009214839-a44d499cefcc h1:KTdzXsjcrnawYH2uNwLW8WVe0vyYmuC8ckpR83Cj7Sg=
github.com/mattermost/rtcd v0.17.2-0.20241009214839-a44d499cefcc/go.mod h1:FVyFLa+7dWImCZ+0g9xoc/1fMRKMuXs6yAZP1mDKBIg=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down
102 changes: 102 additions & 0 deletions server/mocks/github.com/mattermost/rtcd/service/rtc/mock_Metrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions standalone/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"extract": "formatjs extract 'src/**/*.{ts,tsx}' --ignore 'src/**/*.d.ts' --out-file i18n/temp.json --id-interpolation-pattern '[sha512:contenthash:base64:6]' && formatjs compile 'i18n/temp.json' --out-file i18n/en.json && rm i18n/temp.json"
},
"dependencies": {
"@mattermost/calls-common": "github:mattermost/calls-common#39a29e608a2d6ef7927b69c94cbcb5ae87875f12",
"@mattermost/calls-common": "github:mattermost/calls-common#8d2b13bd2f10847a4be461dd4225fef2ade06ab9",
"@mattermost/compass-icons": "0.1.31",
"@msgpack/msgpack": "2.7.1",
"bootstrap": "3.4.1",
Expand Down
6 changes: 3 additions & 3 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"dependencies": {
"@floating-ui/react": "0.26.12",
"@mattermost/calls-common": "github:mattermost/calls-common#39a29e608a2d6ef7927b69c94cbcb5ae87875f12",
"@mattermost/calls-common": "github:mattermost/calls-common#8d2b13bd2f10847a4be461dd4225fef2ade06ab9",
"@msgpack/msgpack": "2.7.1",
"@redux-devtools/extension": "3.2.3",
"core-js": "3.26.1",
Expand Down