convert internal logging to log/slog with structured attributes - #122
Draft
JoshVanL wants to merge 1 commit into
Draft
convert internal logging to log/slog with structured attributes#122JoshVanL wants to merge 1 commit into
JoshVanL wants to merge 1 commit into
Conversation
The backend previously logged through the printf-style backend.Logger
interface, building every message eagerly with fmt verbs. Internal
logging now goes through *slog.Logger with structured attributes; the
public API is unchanged.
backend.Logger and every constructor signature stay exactly as they
were. Callers such as dapr satisfy the interface structurally and keep
compiling untouched. The new backend.SlogFromLogger adapts an incoming
Logger at the constructor boundary:
* A logger from dapr/kit converts in place: records flow through kit's
own slog handler, keeping the dapr log schema, the scope derived from
the logger's name, and any runtime configuration applied to it. This
is what daprd hits, pinned by a regression test.
* Any other implementation, including the stdlib-log DefaultLogger, is
wrapped in a handler that renders records through its printf methods
with attributes appended as key=value pairs, so nothing is dropped.
The exact message layout for such sinks changes slightly (attributes
as a k=v suffix rather than interpolated); nothing asserts on it.
Call sites gain real attributes in place of interpolation. The
pervasive "%v: " instance-ID prefix becomes an instance_id attribute
via derived loggers, and the %s/%s#%d composite keys in the executor
become separate instance_id/activity/event_id attributes.
Two performance fixes on the per-work-item path: HistoryListSummary and
ActionListSummary were built unconditionally on every work item even
with debug disabled; they are now deferred through slog.LogValuer and
cost nothing unless a record is actually emitted. The workflow state
description at orchestration.go is deferred the same way.
Also fixes the postgres backend logging Error("CreateTaskHub",
"failed ...", err) through fmt.Sprint concatenation, which produced a
message with no separators, and distinguishes the previously identical
cleanup-failed and retry-failed warnings in both sqlite and postgres,
which now carry the underlying error.
Signed-off-by: joshvanl <me@joshvanl.dev>
There was a problem hiding this comment.
Pull request overview
Migrates internal logging to structured log/slog while preserving public logger APIs.
Changes:
- Adds adapters for Dapr Kit and printf-style loggers.
- Converts internal logs to structured attributes.
- Defers expensive debug summaries and improves backend error logs.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
go.mod |
Updates dependencies and adds Kit fork replacement. |
go.sum |
Updates dependency checksums. |
client/client_grpc.go |
Adapts the client logger to slog. |
client/worker_grpc.go |
Converts worker-client logs to structured records. |
backend/worker.go |
Adds worker-scoped structured logging. |
backend/taskhub.go |
Converts task-hub lifecycle logging. |
backend/sqlite/sqlite.go |
Structures SQLite warnings and errors. |
backend/postgres/postgres.go |
Structures PostgreSQL warnings and errors. |
backend/orchestration.go |
Adds instance attributes and lazy summaries. |
backend/logger_slog.go |
Implements slog adapters and lazy values. |
backend/logger_slog_test.go |
Tests Kit, bridge, and nil logger paths. |
backend/executor.go |
Structures executor and stream logging. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| modernc.org/memory v1.8.2 // indirect | ||
| ) | ||
|
|
||
| replace github.com/dapr/kit => github.com/joshvanl/kit v0.0.0-20260813182616-fd5d465c8baa |
JoshVanL
marked this pull request as draft
August 14, 2026 18:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The backend previously logged through the printf-style backend.Logger interface, building every message eagerly with fmt verbs. Internal logging now goes through *slog.Logger with structured attributes; the public API is unchanged.
backend.Logger and every constructor signature stay exactly as they were. Callers such as dapr satisfy the interface structurally and keep compiling untouched. The new backend.SlogFromLogger adapts an incoming Logger at the constructor boundary:
Call sites gain real attributes in place of interpolation. The pervasive "%v: " instance-ID prefix becomes an instance_id attribute via derived loggers, and the %s/%s#%d composite keys in the executor become separate instance_id/activity/event_id attributes.
Two performance fixes on the per-work-item path: HistoryListSummary and ActionListSummary were built unconditionally on every work item even with debug disabled; they are now deferred through slog.LogValuer and cost nothing unless a record is actually emitted. The workflow state description at orchestration.go is deferred the same way.
Also fixes the postgres backend logging Error("CreateTaskHub", "failed ...", err) through fmt.Sprint concatenation, which produced a message with no separators, and distinguishes the previously identical cleanup-failed and retry-failed warnings in both sqlite and postgres, which now carry the underlying error.