Use a Twirp server hook to send API call details to telemetry. (#3401)
* Use a Twirp server hook to send API call details to telemetry. * mage generate and clean up * Add project_id * deps * - Redact requests - Do not store responses - Extract top level fields room_name, room_id, participant_identity, participant_id, track_id as appropriate - Store status as int * deps
This commit is contained in:
+13
-2
@@ -499,12 +499,23 @@ func (t *telemetryService) IngressEnded(ctx context.Context, info *livekit.Ingre
|
||||
})
|
||||
}
|
||||
|
||||
func (t *telemetryService) Report(ctx context.Context, report *livekit.ReportInfo) {
|
||||
func (t *telemetryService) Report(ctx context.Context, reportInfo *livekit.ReportInfo) {
|
||||
t.enqueue(func() {
|
||||
ev := &livekit.AnalyticsEvent{
|
||||
Type: livekit.AnalyticsEventType_REPORT,
|
||||
Timestamp: timestamppb.Now(),
|
||||
Report: report,
|
||||
Report: reportInfo,
|
||||
}
|
||||
t.SendEvent(ctx, ev)
|
||||
})
|
||||
}
|
||||
|
||||
func (t *telemetryService) APICall(ctx context.Context, apiCallInfo *livekit.APICallInfo) {
|
||||
t.enqueue(func() {
|
||||
ev := &livekit.AnalyticsEvent{
|
||||
Type: livekit.AnalyticsEventType_API_CALL,
|
||||
Timestamp: timestamppb.Now(),
|
||||
ApiCall: apiCallInfo,
|
||||
}
|
||||
t.SendEvent(ctx, ev)
|
||||
})
|
||||
|
||||
@@ -10,6 +10,12 @@ import (
|
||||
)
|
||||
|
||||
type FakeTelemetryService struct {
|
||||
APICallStub func(context.Context, *livekit.APICallInfo)
|
||||
aPICallMutex sync.RWMutex
|
||||
aPICallArgsForCall []struct {
|
||||
arg1 context.Context
|
||||
arg2 *livekit.APICallInfo
|
||||
}
|
||||
EgressEndedStub func(context.Context, *livekit.EgressInfo)
|
||||
egressEndedMutex sync.RWMutex
|
||||
egressEndedArgsForCall []struct {
|
||||
@@ -263,6 +269,39 @@ type FakeTelemetryService struct {
|
||||
invocationsMutex sync.RWMutex
|
||||
}
|
||||
|
||||
func (fake *FakeTelemetryService) APICall(arg1 context.Context, arg2 *livekit.APICallInfo) {
|
||||
fake.aPICallMutex.Lock()
|
||||
fake.aPICallArgsForCall = append(fake.aPICallArgsForCall, struct {
|
||||
arg1 context.Context
|
||||
arg2 *livekit.APICallInfo
|
||||
}{arg1, arg2})
|
||||
stub := fake.APICallStub
|
||||
fake.recordInvocation("APICall", []interface{}{arg1, arg2})
|
||||
fake.aPICallMutex.Unlock()
|
||||
if stub != nil {
|
||||
fake.APICallStub(arg1, arg2)
|
||||
}
|
||||
}
|
||||
|
||||
func (fake *FakeTelemetryService) APICallCallCount() int {
|
||||
fake.aPICallMutex.RLock()
|
||||
defer fake.aPICallMutex.RUnlock()
|
||||
return len(fake.aPICallArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeTelemetryService) APICallCalls(stub func(context.Context, *livekit.APICallInfo)) {
|
||||
fake.aPICallMutex.Lock()
|
||||
defer fake.aPICallMutex.Unlock()
|
||||
fake.APICallStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeTelemetryService) APICallArgsForCall(i int) (context.Context, *livekit.APICallInfo) {
|
||||
fake.aPICallMutex.RLock()
|
||||
defer fake.aPICallMutex.RUnlock()
|
||||
argsForCall := fake.aPICallArgsForCall[i]
|
||||
return argsForCall.arg1, argsForCall.arg2
|
||||
}
|
||||
|
||||
func (fake *FakeTelemetryService) EgressEnded(arg1 context.Context, arg2 *livekit.EgressInfo) {
|
||||
fake.egressEndedMutex.Lock()
|
||||
fake.egressEndedArgsForCall = append(fake.egressEndedArgsForCall, struct {
|
||||
@@ -1458,6 +1497,8 @@ func (fake *FakeTelemetryService) TrackUnsubscribedArgsForCall(i int) (context.C
|
||||
func (fake *FakeTelemetryService) Invocations() map[string][][]interface{} {
|
||||
fake.invocationsMutex.RLock()
|
||||
defer fake.invocationsMutex.RUnlock()
|
||||
fake.aPICallMutex.RLock()
|
||||
defer fake.aPICallMutex.RUnlock()
|
||||
fake.egressEndedMutex.RLock()
|
||||
defer fake.egressEndedMutex.RUnlock()
|
||||
fake.egressStartedMutex.RLock()
|
||||
|
||||
@@ -76,7 +76,8 @@ 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)
|
||||
Report(ctx context.Context, reportInfo *livekit.ReportInfo)
|
||||
APICall(ctx context.Context, apiCallInfo *livekit.APICallInfo)
|
||||
|
||||
// helpers
|
||||
AnalyticsService
|
||||
|
||||
Reference in New Issue
Block a user