feat(logging): add node identifier to log lines#894
Merged
Conversation
Closes hookdeck#307. Adds an `os.Hostname()`-derived `node` field to every log line so multi-node deployments can be traced from log output alone. Per the issue body, `os.Hostname()` returns sensible identifiers across the relevant deployment targets: - Kubernetes: pod name (e.g. `outpost-api-5bbd447f65-x2444`) - Docker: container ID - ECS: task/container ID - Cloud VMs: instance hostname The hostname is captured once inside `makeLogger` and attached as a default zap field via `zapLogger.With(...)`. Both the main logger and the audit logger pick this up because they share the same construction path. otelzap preserves zap `With` fields, so `Ctx(ctx)` derivations also carry the node identifier. If `os.Hostname()` returns an error, the field falls back to `"unknown"`. This matches the silent-fallback pattern in `internal/redislock/redislock.go` and avoids failing logger construction on observability metadata.
alexluong
reviewed
May 4, 2026
Per @alexluong's review: the hostname attribute should follow the OTEL host semantic convention to avoid confusion with k8s node semantics.
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.
Closes #307.
Adds an
os.Hostname()-derivednodefield to every log line so multi-node deployments can be traced from log output alone. Per the issue body,os.Hostname()returns sensible identifiers across the relevant deployment targets:outpost-api-5bbd447f65-x2444)Implementation
The hostname is captured once inside
makeLoggerand attached as a default zap field viazapLogger.With(zap.String("node", hostname)). Both the main logger and the audit logger pick this up because they share the same construction path.otelzappreserves zapWithfields, soCtx(ctx)derivations also carry the node identifier with no additional wiring.If
os.Hostname()returns an error, the field falls back to"unknown". This matches the silent-fallback pattern ininternal/redislock/redislock.go:136and avoids failing logger construction on observability metadata.Verification
go build ./...: passgo vet ./...: passgo test ./internal/logging/...: pass (no existing test files; the change is structural metadata)Diff
A single 6-line addition in
internal/logging/logger.go. No public surface change.