mirror of
https://github.com/livekit/livekit.git
synced 2026-05-25 09:54:41 +00:00
Structured logging of ParticipantInit (#3279)
* Structured logging of ParticipantInit * use pointer
This commit is contained in:
+48
-16
@@ -20,8 +20,10 @@ import (
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"go.uber.org/atomic"
|
||||
"go.uber.org/zap/zapcore"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/utils"
|
||||
"github.com/livekit/protocol/auth"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
@@ -116,22 +118,6 @@ func (n *NullMessageSource) ConnectionID() livekit.ConnectionID {
|
||||
|
||||
// ------------------------------------------------
|
||||
|
||||
type ParticipantInit struct {
|
||||
Identity livekit.ParticipantIdentity
|
||||
Name livekit.ParticipantName
|
||||
Reconnect bool
|
||||
ReconnectReason livekit.ReconnectReason
|
||||
AutoSubscribe bool
|
||||
Client *livekit.ClientInfo
|
||||
Grants *auth.ClaimGrants
|
||||
Region string
|
||||
AdaptiveStream bool
|
||||
ID livekit.ParticipantID
|
||||
SubscriberAllowPause *bool
|
||||
DisableICELite bool
|
||||
CreateRoom *livekit.CreateRoomRequest
|
||||
}
|
||||
|
||||
// Router allows multiple nodes to coordinate the participant session
|
||||
//
|
||||
//counterfeiter:generate . Router
|
||||
@@ -188,6 +174,52 @@ func CreateRouter(
|
||||
return lr
|
||||
}
|
||||
|
||||
// ------------------------------------------------
|
||||
|
||||
type ParticipantInit struct {
|
||||
Identity livekit.ParticipantIdentity
|
||||
Name livekit.ParticipantName
|
||||
Reconnect bool
|
||||
ReconnectReason livekit.ReconnectReason
|
||||
AutoSubscribe bool
|
||||
Client *livekit.ClientInfo
|
||||
Grants *auth.ClaimGrants
|
||||
Region string
|
||||
AdaptiveStream bool
|
||||
ID livekit.ParticipantID
|
||||
SubscriberAllowPause *bool
|
||||
DisableICELite bool
|
||||
CreateRoom *livekit.CreateRoomRequest
|
||||
}
|
||||
|
||||
func (pi *ParticipantInit) MarshalLogObject(e zapcore.ObjectEncoder) error {
|
||||
if pi == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
logBoolPtr := func(prop string, val *bool) {
|
||||
if val == nil {
|
||||
e.AddString(prop, "not-set")
|
||||
} else {
|
||||
e.AddBool(prop, *val)
|
||||
}
|
||||
}
|
||||
|
||||
e.AddString("Identity", string(pi.Identity))
|
||||
logBoolPtr("Reconnect", &pi.Reconnect)
|
||||
e.AddString("ReconnectReason", pi.ReconnectReason.String())
|
||||
logBoolPtr("AutoSubscribe", &pi.AutoSubscribe)
|
||||
e.AddObject("Client", logger.Proto(utils.ClientInfoWithoutAddress(pi.Client)))
|
||||
e.AddObject("Grants", pi.Grants)
|
||||
e.AddString("Region", pi.Region)
|
||||
logBoolPtr("AdaptiveStream", &pi.AdaptiveStream)
|
||||
e.AddString("ID", string(pi.ID))
|
||||
logBoolPtr("SubscriberAllowPause", pi.SubscriberAllowPause)
|
||||
logBoolPtr("DisableICELite", &pi.DisableICELite)
|
||||
e.AddObject("CreateRoom", logger.Proto(pi.CreateRoom))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pi *ParticipantInit) ToStartSession(roomName livekit.RoomName, connectionID livekit.ConnectionID) (*livekit.StartSession, error) {
|
||||
claims, err := json.Marshal(pi.Grants)
|
||||
if err != nil {
|
||||
|
||||
@@ -344,7 +344,7 @@ func (r *RoomManager) StartSession(
|
||||
|
||||
participant.GetLogger().Infow("resuming RTC session",
|
||||
"nodeID", r.currentNode.NodeID(),
|
||||
"reason", pi.ReconnectReason,
|
||||
"participantInit", &pi,
|
||||
"numParticipants", room.GetParticipantCount(),
|
||||
)
|
||||
iceConfig := r.getIceConfig(room.Name(), participant)
|
||||
@@ -405,12 +405,8 @@ func (r *RoomManager) StartSession(
|
||||
pLogger.Infow("starting RTC session",
|
||||
"room", room.Name(),
|
||||
"nodeID", r.currentNode.NodeID(),
|
||||
"clientInfo", logger.Proto(pi.Client),
|
||||
"reconnect", pi.Reconnect,
|
||||
"reconnectReason", pi.ReconnectReason,
|
||||
"adaptiveStream", pi.AdaptiveStream,
|
||||
"numParticipants", room.GetParticipantCount(),
|
||||
"kind", pi.Grants.GetParticipantKind(),
|
||||
"participantInit", &pi,
|
||||
)
|
||||
|
||||
clientConf := r.clientConfManager.GetConfiguration(pi.Client)
|
||||
|
||||
Reference in New Issue
Block a user