Code inspection (#581)

* Code inspection

* fix [4]int64 conversiong
This commit is contained in:
David Colburn
2022-03-30 13:49:53 -07:00
committed by GitHub
parent 26f7bb498a
commit 0b8a180554
77 changed files with 228 additions and 151 deletions
+2 -2
View File
@@ -6,9 +6,9 @@ import (
"github.com/livekit/protocol/logger"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/livekit/protocol/livekit"
"google.golang.org/protobuf/types/known/timestamppb"
)
type Stat struct {
@@ -307,7 +307,7 @@ func (stats *Stats) computeDeltaStats() *livekit.AnalyticsStat {
maxLayer := int32(-1)
var maxDeltaBytes uint64
//create a map of VideoLayers - to pick max/best layer wrt current and prev
// create a map of VideoLayers - to pick max/best layer wrt current and prev
curLayers := make(map[int32]*livekit.AnalyticsVideoLayer)
// if we have prev, find max delta total bytes for each layer
if prev != nil {
+5 -3
View File
@@ -4,9 +4,11 @@ import (
"context"
"github.com/gammazero/workerpool"
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/webhook"
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
)
const maxWebhookWorkers = 50
@@ -75,8 +77,8 @@ func (t *telemetryServiceInternal) Report(ctx context.Context, stats []*livekit.
totalPackets := uint32(0)
totalBytes := uint64(0)
for _, stream := range stat.Streams {
totalPackets += (stream.TotalPrimaryPackets + stream.TotalRetransmitPackets + stream.TotalPaddingPackets)
totalBytes += (stream.TotalPrimaryBytes + stream.TotalRetransmitBytes + stream.TotalPaddingBytes)
totalPackets += stream.TotalPrimaryPackets + stream.TotalRetransmitPackets + stream.TotalPaddingPackets
totalBytes += stream.TotalPrimaryBytes + stream.TotalRetransmitBytes + stream.TotalPaddingBytes
}
prometheus.IncrementPackets(direction, uint64(totalPackets))
prometheus.IncrementBytes(direction, totalBytes)
@@ -4,11 +4,12 @@ import (
"context"
"time"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/webhook"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
)
@@ -4,8 +4,9 @@ import (
"context"
"testing"
"github.com/livekit/protocol/livekit"
"github.com/stretchr/testify/require"
"github.com/livekit/protocol/livekit"
)
func Test_OnParticipantJoin_EventIsSent(t *testing.T) {
+4 -3
View File
@@ -4,9 +4,10 @@ import (
"context"
"testing"
"github.com/livekit/protocol/livekit"
"github.com/stretchr/testify/require"
"github.com/livekit/protocol/livekit"
"github.com/livekit/livekit-server/pkg/telemetry"
"github.com/livekit/livekit-server/pkg/telemetry/telemetryfakes"
)
@@ -447,7 +448,7 @@ func Test_AnalyticsSentWhenParticipantLeaves(t *testing.T) {
// do
fixture.sut.ParticipantLeft(context.Background(), room, participantInfo)
// should not be called if there are not track stats
// should not be called if there are no track stats
require.Equal(t, 0, fixture.analytics.SendStatsCallCount())
}
@@ -482,7 +483,7 @@ func Test_AddUpTrack(t *testing.T) {
require.Equal(t, 1, len(stats))
require.Equal(t, livekit.StreamType_UPSTREAM, stats[0].Kind)
require.Equal(t, totalBytes, stats[0].Streams[0].TotalPrimaryBytes)
require.Equal(t, totalPackets, uint32(stats[0].Streams[0].TotalPrimaryPackets))
require.Equal(t, totalPackets, stats[0].Streams[0].TotalPrimaryPackets)
require.Equal(t, string(trackID), stats[0].TrackId)
}