mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: convert agent stats to use a table (#6374)
* chore: convert workspace agent stats from json to table * chore: convert agent stats to use a table Backwards compatibility becomes hard when all agent stats are in a JSON blob. We also want to query this table for new agents that are failing health checks so we can display it in the UI. * Fix migration using default values
This commit is contained in:
@@ -397,7 +397,7 @@ func (c *Client) ReportStats(ctx context.Context, log slog.Logger, statsChan <-c
|
||||
}
|
||||
|
||||
// Send an empty stat to get the interval.
|
||||
postStat(&Stats{ConnsByProto: map[string]int64{}})
|
||||
postStat(&Stats{ConnectionsByProto: map[string]int64{}})
|
||||
|
||||
go func() {
|
||||
defer close(exited)
|
||||
@@ -426,10 +426,10 @@ func (c *Client) ReportStats(ctx context.Context, log slog.Logger, statsChan <-c
|
||||
// Stats records the Agent's network connection statistics for use in
|
||||
// user-facing metrics and debugging.
|
||||
type Stats struct {
|
||||
// ConnsByProto is a count of connections by protocol.
|
||||
ConnsByProto map[string]int64 `json:"conns_by_proto"`
|
||||
// NumConns is the number of connections received by an agent.
|
||||
NumConns int64 `json:"num_comms"`
|
||||
// ConnectionsByProto is a count of connections by protocol.
|
||||
ConnectionsByProto map[string]int64 `json:"conns_by_proto"`
|
||||
// ConnectionCount is the number of connections received by an agent.
|
||||
ConnectionCount int64 `json:"num_comms"`
|
||||
// RxPackets is the number of received packets.
|
||||
RxPackets int64 `json:"rx_packets"`
|
||||
// RxBytes is the number of received bytes.
|
||||
|
||||
@@ -79,7 +79,7 @@ func TestAgentReportStats(t *testing.T) {
|
||||
chanLen := 3
|
||||
statCh := make(chan *agentsdk.Stats, chanLen)
|
||||
for i := 0; i < chanLen; i++ {
|
||||
statCh <- &agentsdk.Stats{ConnsByProto: map[string]int64{}}
|
||||
statCh <- &agentsdk.Stats{ConnectionsByProto: map[string]int64{}}
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
Reference in New Issue
Block a user