AnalyticsEvent for generic reports (#3400)
* AnalyticsEvent for generic reports * deps
This commit is contained in:
@@ -499,6 +499,17 @@ func (t *telemetryService) IngressEnded(ctx context.Context, info *livekit.Ingre
|
||||
})
|
||||
}
|
||||
|
||||
func (t *telemetryService) Report(ctx context.Context, report *livekit.ReportInfo) {
|
||||
t.enqueue(func() {
|
||||
ev := &livekit.AnalyticsEvent{
|
||||
Type: livekit.AnalyticsEventType_REPORT,
|
||||
Timestamp: timestamppb.Now(),
|
||||
Report: report,
|
||||
}
|
||||
t.SendEvent(ctx, ev)
|
||||
})
|
||||
}
|
||||
|
||||
// returns a livekit.Room with only name and sid filled out
|
||||
// returns nil if room is not found
|
||||
func (t *telemetryService) getRoomDetails(participantID livekit.ParticipantID) *livekit.Room {
|
||||
|
||||
@@ -110,6 +110,12 @@ type FakeTelemetryService struct {
|
||||
arg4 livekit.NodeID
|
||||
arg5 livekit.ReconnectReason
|
||||
}
|
||||
ReportStub func(context.Context, *livekit.ReportInfo)
|
||||
reportMutex sync.RWMutex
|
||||
reportArgsForCall []struct {
|
||||
arg1 context.Context
|
||||
arg2 *livekit.ReportInfo
|
||||
}
|
||||
RoomEndedStub func(context.Context, *livekit.Room)
|
||||
roomEndedMutex sync.RWMutex
|
||||
roomEndedArgsForCall []struct {
|
||||
@@ -755,6 +761,39 @@ func (fake *FakeTelemetryService) ParticipantResumedArgsForCall(i int) (context.
|
||||
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5
|
||||
}
|
||||
|
||||
func (fake *FakeTelemetryService) Report(arg1 context.Context, arg2 *livekit.ReportInfo) {
|
||||
fake.reportMutex.Lock()
|
||||
fake.reportArgsForCall = append(fake.reportArgsForCall, struct {
|
||||
arg1 context.Context
|
||||
arg2 *livekit.ReportInfo
|
||||
}{arg1, arg2})
|
||||
stub := fake.ReportStub
|
||||
fake.recordInvocation("Report", []interface{}{arg1, arg2})
|
||||
fake.reportMutex.Unlock()
|
||||
if stub != nil {
|
||||
fake.ReportStub(arg1, arg2)
|
||||
}
|
||||
}
|
||||
|
||||
func (fake *FakeTelemetryService) ReportCallCount() int {
|
||||
fake.reportMutex.RLock()
|
||||
defer fake.reportMutex.RUnlock()
|
||||
return len(fake.reportArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeTelemetryService) ReportCalls(stub func(context.Context, *livekit.ReportInfo)) {
|
||||
fake.reportMutex.Lock()
|
||||
defer fake.reportMutex.Unlock()
|
||||
fake.ReportStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeTelemetryService) ReportArgsForCall(i int) (context.Context, *livekit.ReportInfo) {
|
||||
fake.reportMutex.RLock()
|
||||
defer fake.reportMutex.RUnlock()
|
||||
argsForCall := fake.reportArgsForCall[i]
|
||||
return argsForCall.arg1, argsForCall.arg2
|
||||
}
|
||||
|
||||
func (fake *FakeTelemetryService) RoomEnded(arg1 context.Context, arg2 *livekit.Room) {
|
||||
fake.roomEndedMutex.Lock()
|
||||
fake.roomEndedArgsForCall = append(fake.roomEndedArgsForCall, struct {
|
||||
@@ -1449,6 +1488,8 @@ func (fake *FakeTelemetryService) Invocations() map[string][][]interface{} {
|
||||
defer fake.participantLeftMutex.RUnlock()
|
||||
fake.participantResumedMutex.RLock()
|
||||
defer fake.participantResumedMutex.RUnlock()
|
||||
fake.reportMutex.RLock()
|
||||
defer fake.reportMutex.RUnlock()
|
||||
fake.roomEndedMutex.RLock()
|
||||
defer fake.roomEndedMutex.RUnlock()
|
||||
fake.roomStartedMutex.RLock()
|
||||
|
||||
@@ -76,6 +76,7 @@ type TelemetryService interface {
|
||||
IngressUpdated(ctx context.Context, info *livekit.IngressInfo)
|
||||
IngressEnded(ctx context.Context, info *livekit.IngressInfo)
|
||||
LocalRoomState(ctx context.Context, info *livekit.AnalyticsNodeRooms)
|
||||
Report(ctx context.Context, report *livekit.ReportInfo)
|
||||
|
||||
// helpers
|
||||
AnalyticsService
|
||||
|
||||
Reference in New Issue
Block a user