refactor: consolidate duplicate DIFC filtered-item struct and tagsToStrings#2111
Merged
refactor: consolidate duplicate DIFC filtered-item struct and tagsToStrings#2111
Conversation
…trings function - Move shared data fields into logger.FilteredItemLogEntry in jsonl_logger.go - Have JSONLFilteredItem embed FilteredItemLogEntry (adds only Timestamp and Type) - Remove duplicate FilteredItemLogEntry struct from server/difc_log.go - Remove toJSONLFilteredItem() method; use direct struct literal instead - Replace local tagsToStrings() with difc.TagsToStrings - Update difc_log_test.go to use logger.FilteredItemLogEntry Fixes #2085, #2086, #2087 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [duplicate-code] Fix duplicate code patterns in DIFC logging
refactor: consolidate duplicate DIFC filtered-item struct and tagsToStrings
Mar 18, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces duplication in DIFC filtered-item logging by centralizing the shared filtered-item payload fields in the internal/logger package and reusing existing DIFC tag conversion helpers, so future schema changes require fewer parallel edits.
Changes:
- Consolidates the shared filtered-item payload into
logger.FilteredItemLogEntryand embeds it intologger.JSONLFilteredItem. - Simplifies DIFC JSONL emission by removing the per-field conversion helper and using a direct struct literal.
- Replaces the duplicated
tagsToStringshelper indifc_log.gowithdifc.TagsToStrings, and updates tests accordingly.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/server/difc_log.go | Switches filtered-item entry construction to logger.FilteredItemLogEntry, uses difc.TagsToStrings, and simplifies JSONL logging construction. |
| internal/logger/jsonl_logger.go | Introduces FilteredItemLogEntry and embeds it into JSONLFilteredItem to eliminate duplicated field definitions. |
| internal/server/difc_log_test.go | Updates tests to unmarshal/compare against logger.FilteredItemLogEntry. |
💡 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.
This was referenced Mar 18, 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.
Two duplication patterns introduced in
internal/server/difc_log.gorequired parallel edits across files when modifying DIFC filter event data shapes.Changes
Struct consolidation —
FilteredItemLogEntry(server) andJSONLFilteredItem(logger) shared identical 11-field data definitions. Moved the shared fields into a newlogger.FilteredItemLogEntry;JSONLFilteredItemnow embeds it, keeping only its ownTimestampandTypefields:Remove
toJSONLFilteredItem()— field-by-field copy method replaced with a direct struct literal:&logger.JSONLFilteredItem{FilteredItemLogEntry: entry}Eliminate duplicate
tagsToStrings— local helper indifc_log.gowas identical todifc.TagsToStrings; replaced all call sites with the canonical package functionTest updates —
difc_log_test.goupdated to referencelogger.FilteredItemLogEntryinstead of the removed local typeWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
example.com/tmp/go-build3728142662/b332/launcher.test /tmp/go-build3728142662/b332/launcher.test -test.testlogfile=/tmp/go-build3728142662/b332/testlog.txt -test.paniconexit0 -test.timeout=10m0s rev-�� /unix(dns block)invalid-host-that-does-not-exist-12345.com/tmp/go-build3728142662/b317/config.test /tmp/go-build3728142662/b317/config.test -test.testlogfile=/tmp/go-build3728142662/b317/testlog.txt -test.paniconexit0 -test.timeout=10m0s rev-�� ache/go/1.25.8/x-p cf9O/V70NMeR5oSymain x_amd64/vet(dns block)nonexistent.local/tmp/go-build3728142662/b332/launcher.test /tmp/go-build3728142662/b332/launcher.test -test.testlogfile=/tmp/go-build3728142662/b332/testlog.txt -test.paniconexit0 -test.timeout=10m0s rev-�� /unix(dns block)slow.example.com/tmp/go-build3728142662/b332/launcher.test /tmp/go-build3728142662/b332/launcher.test -test.testlogfile=/tmp/go-build3728142662/b332/testlog.txt -test.paniconexit0 -test.timeout=10m0s rev-�� /unix(dns block)this-host-does-not-exist-12345.com/tmp/go-build3728142662/b341/mcp.test /tmp/go-build3728142662/b341/mcp.test -test.testlogfile=/tmp/go-build3728142662/b341/testlog.txt -test.paniconexit0 -test.timeout=10m0s rev-�� ache/go/1.25.8/x64/src/runtime/cgo1.25.8(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.