Fix: msdms log fields emit dash instead of -1 for unset milestones#12900
Merged
bryancall merged 2 commits intoapache:masterfrom Feb 21, 2026
Merged
Fix: msdms log fields emit dash instead of -1 for unset milestones#12900bryancall merged 2 commits intoapache:masterfrom
bryancall merged 2 commits intoapache:masterfrom
Conversation
Add unmarshal_milestone_diff() which outputs a single "-" character when the marshalled value is negative (milestone was unset), instead of the literal string "-1". This makes log parsing cleaner -- parsers can distinguish between "0 ms" (a valid timing) and "not applicable" without checking for a magic integer value. The MSDMS container now uses this new unmarshal function instead of the generic unmarshal_int_to_str.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes how msdms (milestone-delta-in-ms) log fields are rendered in ASCII logs so that unset milestone deltas are emitted as a single - character rather than -1, making downstream parsing distinguish “not applicable” from valid numeric timings.
Changes:
- Add
LogAccess::unmarshal_milestone_diff()to render milestone deltas as-when the marshalled value indicates “unset”. - Switch
LogField’sMSDMScontainer to useunmarshal_milestone_diffinstead of the generic integer unmarshaller. - Expose the new unmarshal helper via
LogAccess.h.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/proxy/logging/LogField.cc |
Uses the new milestone-delta unmarshaller for MSDMS container fields. |
src/proxy/logging/LogAccess.cc |
Implements unmarshal_milestone_diff() to customize formatting of milestone deltas. |
include/proxy/logging/LogAccess.h |
Declares the new unmarshal helper in the LogAccess API. |
Comments suppressed due to low confidence (1)
src/proxy/logging/LogAccess.cc:651
- For consistency with the other integer unmarshal helpers (e.g.,
unmarshal_int_to_str()), the buffer-size guard here should follow the same convention (required_len < len). Usinglen >= 1allows writing when the destination buffer is exactly 1 byte, where other int-to-string helpers would treat it as an overrun. Consider changing this to require1 < len(or otherwise align it with the established checks in this file).
if (val < 0) {
if (len >= 1) {
dest[0] = '-';
return 1;
}
DBG_UNMARSHAL_DEST_OVERRUN
return -1;
Copilot correctly noted that val < 0 would also catch reversed milestone pairs (end < start), hiding potentially useful debug info. Tighten to val == -1 which is the specific "missing" sentinel returned by difference_msec() when a milestone is unset.
zwoop
approved these changes
Feb 21, 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.
Problem
The MSDMS milestone logging fields emit
-1as a literal string when a milestone is unset (i.e.,difference_msec()returns -1 because one or both milestones never fired). Log parsers must treat-1as a magic sentinel to distinguish "0 ms" (valid sub-millisecond timing) from "not applicable."Changes
unmarshal_milestone_diff()function -- outputs a single-character when the marshalled milestone difference equals the -1 sentinel (milestone was unset), instead of emitting the literal string-1. Makes log parsing cleaner: parsers distinguish "0 ms" from "not applicable" without checking for magic integers.LogField.ccnow assignsunmarshal_milestone_diffinstead of the genericunmarshal_int_to_strfor MSDMS fields.Testing
traffic_logcaton binary logs