mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
[adding] kind and client_type to account connect/disconnect events (#2351)
* [adding] kind and client_type to client info. specifically account connect/disconnect events Kind is Client/Leafnode but can take the value of Router/Gateway/JetStream/Account/System in the future. When kind is Client, then client_type is set to mqtt/websocket/nats This fixes #2291 Signed-off-by: Matthias Hanel <mh@synadia.com>
This commit is contained in:
126
server/events.go
126
server/events.go
@@ -53,8 +53,8 @@ const (
|
||||
serverStatsSubj = "$SYS.SERVER.%s.STATSZ"
|
||||
serverDirectReqSubj = "$SYS.REQ.SERVER.%s.%s"
|
||||
serverPingReqSubj = "$SYS.REQ.SERVER.PING.%s"
|
||||
serverStatsPingReqSubj = "$SYS.REQ.SERVER.PING" // use $SYS.REQ.SERVER.PING.STATSZ instead
|
||||
leafNodeConnectEventSubj = "$SYS.ACCOUNT.%s.LEAFNODE.CONNECT"
|
||||
serverStatsPingReqSubj = "$SYS.REQ.SERVER.PING" // use $SYS.REQ.SERVER.PING.STATSZ instead
|
||||
leafNodeConnectEventSubj = "$SYS.ACCOUNT.%s.LEAFNODE.CONNECT" // for internal use only
|
||||
remoteLatencyEventSubj = "$SYS.LATENCY.M2.%s"
|
||||
inboxRespSubj = "$SYS._INBOX.%s.%s"
|
||||
|
||||
@@ -165,23 +165,25 @@ type ServerInfo struct {
|
||||
|
||||
// ClientInfo is detailed information about the client forming a connection.
|
||||
type ClientInfo struct {
|
||||
Start *time.Time `json:"start,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
ID uint64 `json:"id,omitempty"`
|
||||
Account string `json:"acc"`
|
||||
Service string `json:"svc,omitempty"`
|
||||
User string `json:"user,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Lang string `json:"lang,omitempty"`
|
||||
Version string `json:"ver,omitempty"`
|
||||
RTT time.Duration `json:"rtt,omitempty"`
|
||||
Server string `json:"server,omitempty"`
|
||||
Cluster string `json:"cluster,omitempty"`
|
||||
Stop *time.Time `json:"stop,omitempty"`
|
||||
Jwt string `json:"jwt,omitempty"`
|
||||
IssuerKey string `json:"issuer_key,omitempty"`
|
||||
NameTag string `json:"name_tag,omitempty"`
|
||||
Tags jwt.TagList `json:"tags,omitempty"`
|
||||
Start *time.Time `json:"start,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
ID uint64 `json:"id,omitempty"`
|
||||
Account string `json:"acc"`
|
||||
Service string `json:"svc,omitempty"`
|
||||
User string `json:"user,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Lang string `json:"lang,omitempty"`
|
||||
Version string `json:"ver,omitempty"`
|
||||
RTT time.Duration `json:"rtt,omitempty"`
|
||||
Server string `json:"server,omitempty"`
|
||||
Cluster string `json:"cluster,omitempty"`
|
||||
Stop *time.Time `json:"stop,omitempty"`
|
||||
Jwt string `json:"jwt,omitempty"`
|
||||
IssuerKey string `json:"issuer_key,omitempty"`
|
||||
NameTag string `json:"name_tag,omitempty"`
|
||||
Tags jwt.TagList `json:"tags,omitempty"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
ClientType string `json:"client_type,omitempty"`
|
||||
}
|
||||
|
||||
// ServerStats hold various statistics that we will periodically send out.
|
||||
@@ -1440,18 +1442,20 @@ func (s *Server) accountConnectEvent(c *client) {
|
||||
Time: time.Now().UTC(),
|
||||
},
|
||||
Client: ClientInfo{
|
||||
Start: &c.start,
|
||||
Host: c.host,
|
||||
ID: c.cid,
|
||||
Account: accForClient(c),
|
||||
User: c.getRawAuthUser(),
|
||||
Name: c.opts.Name,
|
||||
Lang: c.opts.Lang,
|
||||
Version: c.opts.Version,
|
||||
Jwt: c.opts.JWT,
|
||||
IssuerKey: issuerForClient(c),
|
||||
Tags: c.tags,
|
||||
NameTag: c.nameTag,
|
||||
Start: &c.start,
|
||||
Host: c.host,
|
||||
ID: c.cid,
|
||||
Account: accForClient(c),
|
||||
User: c.getRawAuthUser(),
|
||||
Name: c.opts.Name,
|
||||
Lang: c.opts.Lang,
|
||||
Version: c.opts.Version,
|
||||
Jwt: c.opts.JWT,
|
||||
IssuerKey: issuerForClient(c),
|
||||
Tags: c.tags,
|
||||
NameTag: c.nameTag,
|
||||
Kind: c.kindString(),
|
||||
ClientType: c.clientTypeString(),
|
||||
},
|
||||
}
|
||||
c.mu.Unlock()
|
||||
@@ -1487,20 +1491,22 @@ func (s *Server) accountDisconnectEvent(c *client, now time.Time, reason string)
|
||||
Time: now,
|
||||
},
|
||||
Client: ClientInfo{
|
||||
Start: &c.start,
|
||||
Stop: &now,
|
||||
Host: c.host,
|
||||
ID: c.cid,
|
||||
Account: accForClient(c),
|
||||
User: c.getRawAuthUser(),
|
||||
Name: c.opts.Name,
|
||||
Lang: c.opts.Lang,
|
||||
Version: c.opts.Version,
|
||||
RTT: c.getRTT(),
|
||||
Jwt: c.opts.JWT,
|
||||
IssuerKey: issuerForClient(c),
|
||||
Tags: c.tags,
|
||||
NameTag: c.nameTag,
|
||||
Start: &c.start,
|
||||
Stop: &now,
|
||||
Host: c.host,
|
||||
ID: c.cid,
|
||||
Account: accForClient(c),
|
||||
User: c.getRawAuthUser(),
|
||||
Name: c.opts.Name,
|
||||
Lang: c.opts.Lang,
|
||||
Version: c.opts.Version,
|
||||
RTT: c.getRTT(),
|
||||
Jwt: c.opts.JWT,
|
||||
IssuerKey: issuerForClient(c),
|
||||
Tags: c.tags,
|
||||
NameTag: c.nameTag,
|
||||
Kind: c.kindString(),
|
||||
ClientType: c.clientTypeString(),
|
||||
},
|
||||
Sent: DataStats{
|
||||
Msgs: atomic.LoadInt64(&c.inMsgs),
|
||||
@@ -1536,20 +1542,22 @@ func (s *Server) sendAuthErrorEvent(c *client) {
|
||||
Time: now,
|
||||
},
|
||||
Client: ClientInfo{
|
||||
Start: &c.start,
|
||||
Stop: &now,
|
||||
Host: c.host,
|
||||
ID: c.cid,
|
||||
Account: accForClient(c),
|
||||
User: c.getRawAuthUser(),
|
||||
Name: c.opts.Name,
|
||||
Lang: c.opts.Lang,
|
||||
Version: c.opts.Version,
|
||||
RTT: c.getRTT(),
|
||||
Jwt: c.opts.JWT,
|
||||
IssuerKey: issuerForClient(c),
|
||||
Tags: c.tags,
|
||||
NameTag: c.nameTag,
|
||||
Start: &c.start,
|
||||
Stop: &now,
|
||||
Host: c.host,
|
||||
ID: c.cid,
|
||||
Account: accForClient(c),
|
||||
User: c.getRawAuthUser(),
|
||||
Name: c.opts.Name,
|
||||
Lang: c.opts.Lang,
|
||||
Version: c.opts.Version,
|
||||
RTT: c.getRTT(),
|
||||
Jwt: c.opts.JWT,
|
||||
IssuerKey: issuerForClient(c),
|
||||
Tags: c.tags,
|
||||
NameTag: c.nameTag,
|
||||
Kind: c.kindString(),
|
||||
ClientType: c.clientTypeString(),
|
||||
},
|
||||
Sent: DataStats{
|
||||
Msgs: c.inMsgs,
|
||||
|
||||
Reference in New Issue
Block a user