[log] Add debug logging to difc/sink_server_ids#2034
Merged
Conversation
- Add logSink logger with namespace 'difc:sink_server_ids' - Log input count when SetSinkServerIDs is called - Log when configuration is cleared (empty input) - Log skipped duplicate server IDs during normalization - Log final configured IDs with count after sorting - Log successful sink server ID matches in IsSinkServerID Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds standard debug logging to DIFC sink server ID configuration/lookup to improve observability of which backend server IDs get DIFC tag snapshot enrichment in RPC JSONL logs.
Changes:
- Introduces a
logSinkdebug logger usinglogger.New("difc:sink_server_ids"). - Adds debug logs in
SetSinkServerIDsfor input size, clears, dedup behavior, and final normalized configuration. - Adds a debug log in
IsSinkServerIDon positive matches to trace lookups when enabled.
Comments suppressed due to low confidence (2)
internal/difc/sink_server_ids.go:49
- This final configuration log runs while
sinkServerIDsMuis still held (due to the deferred unlock). Since logging performs formatting + I/O when enabled, it’s better to assignsinkServerIDsunder lock, release the lock, and then log the configured IDs/count to minimize time spent in the critical section.
sort.Strings(normalized)
sinkServerIDs = normalized
logSink.Printf("Sink server IDs configured: count=%d, ids=%v", len(normalized), normalized)
}
internal/difc/sink_server_ids.go:60
IsSinkServerIDperforms debug logging while still holdingsinkServerIDsMu.RLock(). When DEBUG is enabled, this adds formatting + I/O into the locked section and can delay writers (SetSinkServerIDs) unnecessarily. Consider checking for a match under lock, unlocking, then logging/returning based on the result to keep the lock hold time minimal.
for _, sinkServerID := range sinkServerIDs {
if serverID == sinkServerID {
logSink.Printf("Sink server ID match: serverID=%s", serverID)
return true
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
The CI lint job was failing due to a declared-but-never-read variable
`cleared` in `internal/difc/sink_server_ids.go`. The variable was
assigned `true` in the empty-input early-return branch but the function
returns immediately after, so the value was never consumed.
## Change
- **`internal/difc/sink_server_ids.go`**: Remove `cleared bool` from the
`var` block and drop its assignment — the existing `logSink.Print` call
already communicates the clearing behaviour.
```go
// Before
var (
cleared bool
normalizedOut []string
duplicateIDs []string
)
// ...
sinkServerIDs = nil
cleared = true // assigned, never read
// After
var (
normalizedOut []string
duplicateIDs []string
)
// ...
sinkServerIDs = nil
```
<!-- START COPILOT CODING AGENT SUFFIX -->
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
> Fix the failing GitHub Actions workflow lint
> Analyze the workflow logs, identify the root cause of the failure, and
implement a fix.
> Job ID: 67273885685
> Job URL:
https://github.com/github/gh-aw-mcpg/actions/runs/23156873563/job/67273885685
</details>
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 Send tasks to Copilot coding agent from
[Slack](https://gh.io/cca-slack-docs) and
[Teams](https://gh.io/cca-teams-docs) to turn conversations into code.
Copilot posts an update in your thread when it's finished.
This was referenced Mar 16, 2026
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.
Summary
Adds a debug logger (
logSink) tointernal/difc/sink_server_ids.gousing the project's standardlogger.New("difc:sink_server_ids")pattern. This file configures which backend server IDs receive DIFC tag snapshot enrichment in RPC JSONL logs, and previously had no debug visibility.Changes
File modified:
internal/difc/sink_server_ids.gologgerimport andvar logSink = logger.New("difc:sink_server_ids")declarationSetSinkServerIDs: logs input count on entry, logs when config is cleared, logs skipped duplicate IDs, logs final normalized IDs and count after sortingIsSinkServerID: logs when a match is found (called frequently, so only logs on positive match to minimize noise)Logging calls added (5 total)
SetSinkServerIDsentrySetting sink server IDs: input_count=NSetSinkServerIDsempty caseNo sink server IDs provided, clearing configurationSetSinkServerIDsloopSkipping duplicate sink server ID: %sSetSinkServerIDsendSink server IDs configured: count=N, ids=[...]IsSinkServerIDmatchSink server ID match: serverID=%sLogger naming convention
Follows
pkg:filenameconvention:"difc:sink_server_ids"forinternal/difc/sink_server_ids.go.Testing
Enable with
DEBUG=difc:* ./awmg --config config.tomlto see all difc debug logs including the new sink server ID logs.