Skip to content

[log] Add debug logging to difc/sink_server_ids#2034

Merged
lpcox merged 5 commits intomainfrom
log/difc-sink-server-ids-37cf5ef4349005f5
Mar 16, 2026
Merged

[log] Add debug logging to difc/sink_server_ids#2034
lpcox merged 5 commits intomainfrom
log/difc-sink-server-ids-37cf5ef4349005f5

Conversation

@github-actions
Copy link
Contributor

Summary

Adds a debug logger (logSink) to internal/difc/sink_server_ids.go using the project's standard logger.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.go

  • Added logger import and var logSink = logger.New("difc:sink_server_ids") declaration
  • SetSinkServerIDs: logs input count on entry, logs when config is cleared, logs skipped duplicate IDs, logs final normalized IDs and count after sorting
  • IsSinkServerID: logs when a match is found (called frequently, so only logs on positive match to minimize noise)

Logging calls added (5 total)

Location Message Purpose
SetSinkServerIDs entry Setting sink server IDs: input_count=N Trace configuration calls
SetSinkServerIDs empty case No sink server IDs provided, clearing configuration Visible config reset
SetSinkServerIDs loop Skipping duplicate sink server ID: %s Debug dedup logic
SetSinkServerIDs end Sink server IDs configured: count=N, ids=[...] Final state confirmation
IsSinkServerID match Sink server ID match: serverID=%s Trace positive lookups

Logger naming convention

Follows pkg:filename convention: "difc:sink_server_ids" for internal/difc/sink_server_ids.go.

Testing

Enable with DEBUG=difc:* ./awmg --config config.toml to see all difc debug logs including the new sink server ID logs.

Generated by Go Logger Enhancement ·

- 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>
@github-actions github-actions bot added automation enhancement New feature or request labels Mar 16, 2026
@lpcox lpcox marked this pull request as ready for review March 16, 2026 16:27
Copilot AI review requested due to automatic review settings March 16, 2026 16:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 logSink debug logger using logger.New("difc:sink_server_ids").
  • Adds debug logs in SetSinkServerIDs for input size, clears, dedup behavior, and final normalized configuration.
  • Adds a debug log in IsSinkServerID on 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 sinkServerIDsMu is still held (due to the deferred unlock). Since logging performs formatting + I/O when enabled, it’s better to assign sinkServerIDs under 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

  • IsSinkServerID performs debug logging while still holding sinkServerIDsMu.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.

lpcox and others added 4 commits March 16, 2026 10:23
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.
@lpcox lpcox merged commit a774683 into main Mar 16, 2026
13 checks passed
@lpcox lpcox deleted the log/difc-sink-server-ids-37cf5ef4349005f5 branch March 16, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants