Repository navigation
Description
Related to #2387
Goal
The two DEBUG lines that announce the UDP core statistics events (UdpAnnounce, UdpScrape) are logged under the UDP TRACKER log target, like every other UDP core log line, so per-target log filtering and the target of structured logs are correct.
Background
Found while working on #3031 (EPIC #2387); it was not part of that issue.
What happens, step by step. packages/udp-core/src/services/announce.rs:178 and packages/udp-core/src/services/scrape.rs:140 are written as:
tracing::debug!(target = crate::UDP_TRACKER_LOG_TARGET, "Sending UdpAnnounce event: {event:?}");In tracing, target = value (an equals sign) is an ordinary field named target; the log target is set only with target: value (a colon). So:
send_eventpublishes a statistics event and logs the DEBUG line.tracingrecords the target as the default, the module path (torrust_tracker_udp_core::services::announce).- The intended value
UDP TRACKERis recorded as a stray fieldtarget="UDP TRACKER"at the end of the line.
Expectation violated. Every other call site in the repository sets the target with the colon form: 111 call sites use target: ..._LOG_TARGET, including the other UDP_TRACKER_LOG_TARGET users in packages/udp-core (banning.rs, statistics/event/listener.rs). The constant is exported precisely so UDP core lines share one target.
Impact. Only DEBUG output is affected, and nothing is functionally wrong. A consumer that selects log lines by target (a grep for UDP TRACKER, the target key of the JSON log style, a log shipper's filter) misses these two lines, and for the JSON style the record carries a wrong target plus a stray target field. The EPIC #2387 logging conventions rely on named targets.
Verified scope (2026-11-25, torrust/develop at the merge of #3053). git grep -nE '\(\s*target\s*=' -- '*.rs' and a multi-line variant find exactly these two sites; no other tracing macro, span! or event! in packages or src has the mistake. The grep is the check for AC3.
Scope
In Scope
- Change the two call sites to
target: crate::UDP_TRACKER_LOG_TARGET. - Two maintained regression tests (announce and scrape) asserting the captured line carries the
UDP TRACKERtarget. - A guard against the mistake coming back (see Design Decision).
Out of Scope
- Changing log levels, messages or other targets (EPIC Make tracker startup and shutdown logs coherent for operators #2387 owns those).
- Making this a sub-issue of Make tracker startup and shutdown logs coherent for operators #2387: it is standalone;
Related to #2387is context only.
Design Decision
The fix is the two-character change from = to :. Whether to also add a lint to catch the mistake is open for the maintainer: clippy does not flag it (the macro accepts the field form as valid). Proposed default: no new lint; the two regression tests and the git grep in AC3 are enough for two sites. A repository-wide guard (for example a git grep step in linter) can be a separate issue if wanted.
Architectural Decisions
- Related ADRs: none known. The logging convention is in EPIC Make tracker startup and shutdown logs coherent for operators #2387's ADR work (SI-2).
- ADRs to create: None known.
Design and Ownership Review
Not applicable.
Bug-Fix Process
Follows .claude/skills/fix-bug/SKILL.md:
- Analysis: the field-versus-target macro syntax in the two call sites (above).
- Reproduction: V1, done on 2026-11-25: a temporary test captured the real DEBUG line of both services. Outcome: Reproduced.
- Regression-test boundary: see below.
- Red test: recorded before the fix.
- Fix:
=to:at both sites. - Green and recheck: regression tests green, then V1 rerun after the last production change.
Regression Test Strategy
- Boundary: a unit test in each of
announce.rsandscrape.rs(the existing#[cfg(test)]modules, next toit_should_publish_..._event). It builds the service with a mock event sender, callshandle_announce/handle_scrapeinsidetorrust_tracker_test_helpers::logging::capture_logs_while(the scoped, thread-local capture helper added by Bug: statistics listeners log a WARN for every event when usage statistics are disabled #3031; the handoff called itcapture_logs_in_scope, ondevelopit iscapture_logs_while), on acurrent_threadruntime because the subscriber is thread-local, and asserts the captured line containsUDP TRACKER: Sending UdpAnnounce event(resp.UdpScrape) and does not contain the module-path prefix. Thefmtsubscriber prints<target>: <message>, so the assertion is on the target itself. - Why this boundary: it is the smallest deterministic test that exercises the causal macro call; the symptom is only visible in the emitted record.
- Evidence: red and green output in
manual-verification-evidence.md.
Implementation Plan
Status values: TODO, IN_PROGRESS, BLOCKED, DONE.
| ID | Status | Task | Notes / Expected Output |
|---|---|---|---|
| T1 | DONE | Reproduce on both services and record it | V1 recorded in manual-verification-evidence.md |
| T2 | TODO | Add the announce and scrape regression tests and observe them red | Red run recorded on the unfixed code, both tests failing |
| T3 | TODO | Change = to : at both call sites |
Regression tests green |
| T4 | TODO | Rerun V1 after the last production change; run linter all |
Evidence names the commit by Conventional Commit subject |
Commit Points
| Task | Coherent change set | Commit policy |
|---|---|---|
| T2 | The two regression tests plus their red evidence | Commit after focused validation and required review. |
| T3 | The two-site production fix | Commit after focused validation and required review. |
| T4 | Final evidence and spec progress | Commit after focused validation and required review. |
Record a justified no-change decision in the task's evidence without creating an empty commit. For test-producing work, use the write-unit-test skill and complete an explicit design review after each passing test increment, before maintainer review and commit, using the mandatory prose-first Arrange-Act-Assert comparison. Use a Conventional Commit message with the narrow affected scope, and sign every commit with GPG.
Activity
docs(issues): [torrust#3060] plan the regression tests on capture_log…
docs(issues): [torrust#3060] make AC3 a multi-line scan and state the…
docs(issues): [torrust#3060] record the V1 reproduction verbatim for …
docs(issues): [torrust#3060] state that send_event logs before it pub…
docs(issues): [torrust#3060] strip the trailing space from the record…
docs(issues): [torrust#3060] capitalize the Verified scope sentence
docs(pr-reviews): [torrust#3060] record the review audit of PR 3062
docs(issues): [torrust#3060] scan for the field form with GNU grep so…
docs(pr-reviews): [torrust#3060] record the second review round of PR…
docs(issues): [torrust#3060] let the AC3 scan skip earlier arguments …
docs(pr-reviews): [torrust#3060] record the third review round of PR …
docs(issues): [torrust#3060] limit the AC3 claim to one level of pare…
docs(pr-reviews): [torrust#3060] record the fourth review round of PR…
7 remaining items
docs(issues): [torrust#3060] record the prose-first Arrange-Act-Asser…
docs(pr-reviews): [torrust#3060] record the review audit of PR 3078
docs(issues): [torrust#2766] say that issue torrust#3060 is open and …
docs(pr-reviews): [torrust#3060] cite the audited head by commit subj…
docs(pr-reviews): [torrust#3060] log the correction of the cited head…
docs(pr-reviews): [torrust#3060] record the second review round of PR…
docs(pr-reviews): [torrust#3060] name every issue comment without a r…
docs(pr-reviews): [torrust#3060] record the third review round of PR …
test(udp-core): [#3060] assert the UDP core event DEBUG lines are log…
fix(udp-core): [#3060] set the UDP TRACKER log target of the event DE…
docs(issues): [#3060] record the green run, the V1 recheck and the AC…
Merge torrust#3078: fix(udp-core): [torrust#3060] set the UDP TRACKER…
docs(issues): [#2766] point the two mistaken udp-core events to issue #…
Merge #3081: docs(issues): refresh the daemon JSON logging spec and r…