mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: fix slog to always use array of Fields (#21426)
Upgrades to slog v3 which includes a small, but backward incompatible API change to the acceptible call arguments when logging. This change allows us to verify via compile time type checking that arguments are correct and won't cause a panic, as was possible in slog v1, which this replaces (v2 was tagged but never used in coder/coder). It also updates dependencies that also use slog and were updated. I've left the `aibridge` dependency as a commit SHA, under the assumption that the team there (cc @pawbana @dannykopping ) will tag and update the dependency soon and on their own schedule. Other dependencies, I pushed new tags.
This commit is contained in:
@@ -23,7 +23,8 @@ import (
|
||||
"golang.org/x/xerrors"
|
||||
"tailscale.com/tailcfg"
|
||||
|
||||
"cdr.dev/slog"
|
||||
"cdr.dev/slog/v3"
|
||||
|
||||
"github.com/coder/websocket"
|
||||
|
||||
"github.com/coder/coder/v2/coderd/agentapi"
|
||||
@@ -1740,7 +1741,7 @@ func (api *API) watchWorkspaceAgentMetadata(
|
||||
return
|
||||
}
|
||||
|
||||
log.Debug(ctx, "received metadata update", "payload", payload)
|
||||
log.Debug(ctx, "received metadata update", slog.F("payload", payload))
|
||||
|
||||
select {
|
||||
case prev := <-update:
|
||||
@@ -1770,7 +1771,7 @@ func (api *API) watchWorkspaceAgentMetadata(
|
||||
return
|
||||
}
|
||||
|
||||
log.Debug(ctx, "got initial metadata", "num", len(initialMD))
|
||||
log.Debug(ctx, "got initial metadata", slog.F("num", len(initialMD)))
|
||||
|
||||
metadataMap := make(map[string]database.WorkspaceAgentMetadatum, len(initialMD))
|
||||
for _, datum := range initialMD {
|
||||
@@ -1807,7 +1808,7 @@ func (api *API) watchWorkspaceAgentMetadata(
|
||||
lastSend = time.Now()
|
||||
values := maps.Values(metadataMap)
|
||||
|
||||
log.Debug(ctx, "sending metadata", "num", len(values))
|
||||
log.Debug(ctx, "sending metadata", slog.F("num", len(values)))
|
||||
|
||||
_ = sendEvent(codersdk.ServerSentEvent{
|
||||
Type: codersdk.ServerSentEventTypeData,
|
||||
@@ -1862,7 +1863,9 @@ func (api *API) watchWorkspaceAgentMetadata(
|
||||
// We want to block here to avoid constantly pinging the
|
||||
// database when the metadata isn't being processed.
|
||||
case fetchedMetadata <- md:
|
||||
log.Debug(ctx, "fetched metadata update for keys", "keys", payload.Keys, "num", len(md))
|
||||
log.Debug(ctx, "fetched metadata update for keys",
|
||||
slog.F("keys", payload.Keys),
|
||||
slog.F("num", len(md)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user