Structured logging of ParticipantInit (#3279)
* Structured logging of ParticipantInit * use pointer
This commit is contained in:
@@ -21,7 +21,7 @@ require (
|
|||||||
github.com/jxskiss/base62 v1.1.0
|
github.com/jxskiss/base62 v1.1.0
|
||||||
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1
|
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1
|
||||||
github.com/livekit/mediatransportutil v0.0.0-20241220010243-a2bdee945564
|
github.com/livekit/mediatransportutil v0.0.0-20241220010243-a2bdee945564
|
||||||
github.com/livekit/protocol v1.29.5-0.20241219224350-c87b1afc6161
|
github.com/livekit/protocol v1.29.5-0.20241220052646-970d4dcfad8d
|
||||||
github.com/livekit/psrpc v0.6.1-0.20241018124827-1efff3d113a8
|
github.com/livekit/psrpc v0.6.1-0.20241018124827-1efff3d113a8
|
||||||
github.com/mackerelio/go-osstat v0.2.5
|
github.com/mackerelio/go-osstat v0.2.5
|
||||||
github.com/magefile/mage v1.15.0
|
github.com/magefile/mage v1.15.0
|
||||||
|
|||||||
@@ -167,8 +167,8 @@ github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 h1:jm09419p0lqTkD
|
|||||||
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
|
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
|
||||||
github.com/livekit/mediatransportutil v0.0.0-20241220010243-a2bdee945564 h1:GX7KF/V9ExmcfT/2Bdia8aROjkxrgx7WpyH7w9MB4J4=
|
github.com/livekit/mediatransportutil v0.0.0-20241220010243-a2bdee945564 h1:GX7KF/V9ExmcfT/2Bdia8aROjkxrgx7WpyH7w9MB4J4=
|
||||||
github.com/livekit/mediatransportutil v0.0.0-20241220010243-a2bdee945564/go.mod h1:36s+wwmU3O40IAhE+MjBWP3W71QRiEE9SfooSBvtBqY=
|
github.com/livekit/mediatransportutil v0.0.0-20241220010243-a2bdee945564/go.mod h1:36s+wwmU3O40IAhE+MjBWP3W71QRiEE9SfooSBvtBqY=
|
||||||
github.com/livekit/protocol v1.29.5-0.20241219224350-c87b1afc6161 h1:IT5WQA+96qmLOkffNKrp5qNuupzf/9O+xIdvGjv5JCI=
|
github.com/livekit/protocol v1.29.5-0.20241220052646-970d4dcfad8d h1:c1apaZ6oGVdIUfeeTBn6yZFRJ8ROdW9TFguz4zsWRBM=
|
||||||
github.com/livekit/protocol v1.29.5-0.20241219224350-c87b1afc6161/go.mod h1:08wT2rI6GecTCwh9n8OA28Gb7ZQNtIR+hX/LccP1TaY=
|
github.com/livekit/protocol v1.29.5-0.20241220052646-970d4dcfad8d/go.mod h1:08wT2rI6GecTCwh9n8OA28Gb7ZQNtIR+hX/LccP1TaY=
|
||||||
github.com/livekit/psrpc v0.6.1-0.20241018124827-1efff3d113a8 h1:Ibh0LoFl5NW5a1KFJEE0eLxxz7dqqKmYTj/BfCb0PbY=
|
github.com/livekit/psrpc v0.6.1-0.20241018124827-1efff3d113a8 h1:Ibh0LoFl5NW5a1KFJEE0eLxxz7dqqKmYTj/BfCb0PbY=
|
||||||
github.com/livekit/psrpc v0.6.1-0.20241018124827-1efff3d113a8/go.mod h1:CQUBSPfYYAaevg1TNCc6/aYsa8DJH4jSRFdCeSZk5u0=
|
github.com/livekit/psrpc v0.6.1-0.20241018124827-1efff3d113a8/go.mod h1:CQUBSPfYYAaevg1TNCc6/aYsa8DJH4jSRFdCeSZk5u0=
|
||||||
github.com/mackerelio/go-osstat v0.2.5 h1:+MqTbZUhoIt4m8qzkVoXUJg1EuifwlAJSk4Yl2GXh+o=
|
github.com/mackerelio/go-osstat v0.2.5 h1:+MqTbZUhoIt4m8qzkVoXUJg1EuifwlAJSk4Yl2GXh+o=
|
||||||
|
|||||||
+48
-16
@@ -20,8 +20,10 @@ import (
|
|||||||
|
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
"go.uber.org/atomic"
|
"go.uber.org/atomic"
|
||||||
|
"go.uber.org/zap/zapcore"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
|
|
||||||
|
"github.com/livekit/livekit-server/pkg/utils"
|
||||||
"github.com/livekit/protocol/auth"
|
"github.com/livekit/protocol/auth"
|
||||||
"github.com/livekit/protocol/livekit"
|
"github.com/livekit/protocol/livekit"
|
||||||
"github.com/livekit/protocol/logger"
|
"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
|
// Router allows multiple nodes to coordinate the participant session
|
||||||
//
|
//
|
||||||
//counterfeiter:generate . Router
|
//counterfeiter:generate . Router
|
||||||
@@ -188,6 +174,52 @@ func CreateRouter(
|
|||||||
return lr
|
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) {
|
func (pi *ParticipantInit) ToStartSession(roomName livekit.RoomName, connectionID livekit.ConnectionID) (*livekit.StartSession, error) {
|
||||||
claims, err := json.Marshal(pi.Grants)
|
claims, err := json.Marshal(pi.Grants)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ func (r *RoomManager) StartSession(
|
|||||||
|
|
||||||
participant.GetLogger().Infow("resuming RTC session",
|
participant.GetLogger().Infow("resuming RTC session",
|
||||||
"nodeID", r.currentNode.NodeID(),
|
"nodeID", r.currentNode.NodeID(),
|
||||||
"reason", pi.ReconnectReason,
|
"participantInit", &pi,
|
||||||
"numParticipants", room.GetParticipantCount(),
|
"numParticipants", room.GetParticipantCount(),
|
||||||
)
|
)
|
||||||
iceConfig := r.getIceConfig(room.Name(), participant)
|
iceConfig := r.getIceConfig(room.Name(), participant)
|
||||||
@@ -405,12 +405,8 @@ func (r *RoomManager) StartSession(
|
|||||||
pLogger.Infow("starting RTC session",
|
pLogger.Infow("starting RTC session",
|
||||||
"room", room.Name(),
|
"room", room.Name(),
|
||||||
"nodeID", r.currentNode.NodeID(),
|
"nodeID", r.currentNode.NodeID(),
|
||||||
"clientInfo", logger.Proto(pi.Client),
|
|
||||||
"reconnect", pi.Reconnect,
|
|
||||||
"reconnectReason", pi.ReconnectReason,
|
|
||||||
"adaptiveStream", pi.AdaptiveStream,
|
|
||||||
"numParticipants", room.GetParticipantCount(),
|
"numParticipants", room.GetParticipantCount(),
|
||||||
"kind", pi.Grants.GetParticipantKind(),
|
"participantInit", &pi,
|
||||||
)
|
)
|
||||||
|
|
||||||
clientConf := r.clientConfManager.GetConfiguration(pi.Client)
|
clientConf := r.clientConfManager.GetConfiguration(pi.Client)
|
||||||
|
|||||||
Reference in New Issue
Block a user