diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index 1992d4015..1988052d9 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -2867,6 +2867,7 @@ func (p *ParticipantImpl) addPendingTrackLocked(req *livekit.AddTrackRequest) *l "falling back to alternative video codec", "codec", mimeType, "altCodec", altCodec, + "enabledPublishCodecs", logger.ProtoSlice(p.enabledPublishCodecs), "trackID", ti.Sid, ) // select an alternative MIME type that's generally supported @@ -2894,6 +2895,7 @@ func (p *ParticipantImpl) addPendingTrackLocked(req *livekit.AddTrackRequest) *l "falling back to alternative audio codec", "codec", mimeType, "altCodec", altCodec, + "enabledPublishCodecs", logger.ProtoSlice(p.enabledPublishCodecs), "trackID", ti.Sid, ) // select an alternative MIME type that's generally supported diff --git a/pkg/service/twirp.go b/pkg/service/twirp.go index 67d6ad8fe..51055671d 100644 --- a/pkg/service/twirp.go +++ b/pkg/service/twirp.go @@ -70,6 +70,14 @@ type twirpLogger struct { fieldsOrig []any fields []any startedAt time.Time + deadline time.Time +} + +func (t *twirpLogger) reset() { + t.fields = t.fieldsOrig + t.error = nil + t.startedAt = time.Time{} + t.deadline = time.Time{} } func AppendLogFields(ctx context.Context, fields ...any) { @@ -84,6 +92,9 @@ func AppendLogFields(ctx context.Context, fields ...any) { func loggerRequestReceived(ctx context.Context, twirpLoggerPool *sync.Pool) (context.Context, error) { r := twirpLoggerPool.Get().(*twirpLogger) r.startedAt = time.Now() + if deadline, ok := ctx.Deadline(); ok { + r.deadline = deadline + } r.fields = r.fieldsOrig r.error = nil @@ -115,6 +126,9 @@ func loggerResponseSent(ctx context.Context, twirpLoggerPool *sync.Pool) { } r.fields = append(r.fields, "duration", time.Since(r.startedAt)) + if !r.deadline.IsZero() { + r.fields = append(r.fields, "timeout", r.deadline.Sub(r.startedAt)) + } if status, ok := twirp.StatusCode(ctx); ok { r.fields = append(r.fields, "status", status) @@ -127,9 +141,8 @@ func loggerResponseSent(ctx context.Context, twirpLoggerPool *sync.Pool) { serviceMethod := "API " + r.service + "." + r.method utils.GetLogger(ctx).WithComponent(utils.ComponentAPI).Infow(serviceMethod, r.fields...) - r.fields = r.fieldsOrig - r.error = nil - + // reset fields and return to pool + r.reset() twirpLoggerPool.Put(r) }