Separate calls to Telemetry vs Prometheus room lifecycle (#935)

* Separate calls to Telemetry vs Prometheus room lifecycle

* remove unused import
This commit is contained in:
David Zhao
2022-08-20 20:22:16 -07:00
committed by GitHub
parent 26ba69c506
commit b8bda3f14b
2 changed files with 6 additions and 7 deletions
+5 -1
View File
@@ -8,6 +8,7 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
"github.com/livekit/livekit-server/version" "github.com/livekit/livekit-server/version"
"github.com/livekit/protocol/auth" "github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit" "github.com/livekit/protocol/livekit"
@@ -379,7 +380,9 @@ func (r *RoomManager) getOrCreateRoom(ctx context.Context, roomName livekit.Room
newRoom := rtc.NewRoom(ri, *r.rtcConfig, &r.config.Audio, r.serverInfo, r.telemetry) newRoom := rtc.NewRoom(ri, *r.rtcConfig, &r.config.Audio, r.serverInfo, r.telemetry)
newRoom.OnClose(func() { newRoom.OnClose(func() {
r.telemetry.RoomEnded(ctx, newRoom.ToProto()) roomInfo := newRoom.ToProto()
r.telemetry.RoomEnded(ctx, roomInfo)
prometheus.RoomEnded(time.Unix(roomInfo.CreationTime, 0))
if err := r.DeleteRoom(ctx, roomName); err != nil { if err := r.DeleteRoom(ctx, roomName); err != nil {
newRoom.Logger.Errorw("could not delete room", err) newRoom.Logger.Errorw("could not delete room", err)
} }
@@ -408,6 +411,7 @@ func (r *RoomManager) getOrCreateRoom(ctx context.Context, roomName livekit.Room
newRoom.Hold() newRoom.Hold()
r.telemetry.RoomStarted(ctx, newRoom.ToProto()) r.telemetry.RoomStarted(ctx, newRoom.ToProto())
prometheus.RoomStarted()
return newRoom, nil return newRoom, nil
} }
@@ -15,8 +15,6 @@ import (
) )
func (t *telemetryServiceInternal) RoomStarted(ctx context.Context, room *livekit.Room) { func (t *telemetryServiceInternal) RoomStarted(ctx context.Context, room *livekit.Room) {
prometheus.RoomStarted()
t.notifyEvent(ctx, &livekit.WebhookEvent{ t.notifyEvent(ctx, &livekit.WebhookEvent{
Event: webhook.EventRoomStarted, Event: webhook.EventRoomStarted,
Room: room, Room: room,
@@ -30,8 +28,6 @@ func (t *telemetryServiceInternal) RoomStarted(ctx context.Context, room *liveki
} }
func (t *telemetryServiceInternal) RoomEnded(ctx context.Context, room *livekit.Room) { func (t *telemetryServiceInternal) RoomEnded(ctx context.Context, room *livekit.Room) {
prometheus.RoomEnded(time.Unix(room.CreationTime, 0))
t.notifyEvent(ctx, &livekit.WebhookEvent{ t.notifyEvent(ctx, &livekit.WebhookEvent{
Event: webhook.EventRoomFinished, Event: webhook.EventRoomFinished,
Room: room, Room: room,
@@ -53,6 +49,7 @@ func (t *telemetryServiceInternal) ParticipantJoined(
clientMeta *livekit.AnalyticsClientMeta, clientMeta *livekit.AnalyticsClientMeta,
) { ) {
prometheus.IncrementParticipantJoin(1) prometheus.IncrementParticipantJoin(1)
prometheus.AddParticipant()
newWorker := newStatsWorker( newWorker := newStatsWorker(
ctx, ctx,
@@ -81,8 +78,6 @@ func (t *telemetryServiceInternal) ParticipantJoined(
} }
t.workersMu.Unlock() t.workersMu.Unlock()
prometheus.AddParticipant()
t.analytics.SendEvent(ctx, &livekit.AnalyticsEvent{ t.analytics.SendEvent(ctx, &livekit.AnalyticsEvent{
Type: livekit.AnalyticsEventType_PARTICIPANT_JOINED, Type: livekit.AnalyticsEventType_PARTICIPANT_JOINED,
Timestamp: timestamppb.Now(), Timestamp: timestamppb.Now(),