Preserve console log timestamps and normalize carriage-return output#16796
Conversation
Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/db6cb5cb-e08f-41ec-9cab-d1b240212f6e Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/db6cb5cb-e08f-41ec-9cab-d1b240212f6e Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/db6cb5cb-e08f-41ec-9cab-d1b240212f6e Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/db6cb5cb-e08f-41ec-9cab-d1b240212f6e Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com>
|
@copilot change the code so that |
Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/3c9c7575-244c-44de-ab64-614b0f7e8973 Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com>
Addressed in c29ae01 by removing raw log line preservation from Warning 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16796Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16796" |
There was a problem hiding this comment.
Pull request overview
Fixes log ordering issues in the hosting/DCP log ingestion pipeline by preserving timestamps for DCP [sys] messages and normalizing terminal-style carriage-return (\r) output so progress updates (e.g., curl) don’t produce timestamp-less fragments.
Changes:
- Extend
DcpLogParserto extract a timestamp from DCP-formatted log lines (UTC and offset forms) and add parser coverage. - Carry timestamp metadata through
ResourceLogSourcevia a newResourceLogEntrytype, and prefer that timestamp inDcpResourceWatcherwhen creatingLogEntryinstances. - Replace
ReadLineAsyncingestion with a custom reader that terminates on\n/\r\nwhile preserving standalone\rlong enough to normalize overwrite behavior; add regression tests for sys timestamps and curl-like progress output.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.Tests/Dcp/DcpLogParserTests.cs | Adds coverage for UTC and offset timestamp parsing in DCP log lines. |
| tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs | Adds regression tests for [sys] timestamp preservation and \r progress normalization. |
| src/Aspire.Hosting/Dcp/ResourceLogSource.cs | Introduces ResourceLogEntry with timestamp metadata and a custom line reader + \r normalization. |
| src/Aspire.Hosting/Dcp/DcpResourceWatcher.cs | Consumes ResourceLogEntry timestamps to create LogEntry instances without re-parsing formatted [sys] content. |
| src/Aspire.Hosting/Dcp/DcpLogParser.cs | Adds new TryParseDcpLog overloads that extract a timestamp from the first tab-delimited field. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…mestamps in export path Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/8225b8c8-ec38-47af-b955-f82f15695d9d Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
🎬 CLI E2E Test Recordings — 64 recordings uploaded (commit View all recordings
📹 Recordings uploaded automatically from CI run #25409294198 |
JamesNK
left a comment
There was a problem hiding this comment.
Looks good overall — the timestamp preservation, CR normalization, isError per-iteration fix, and RawContent plumbing are well done. One potential correctness issue noted inline (normalization ordering vs. DCP parsing for the system stream).
Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/7237c511-0243-48a5-b39e-7e33c098d724 Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/7237c511-0243-48a5-b39e-7e33c098d724 Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot The ResourceLogging_CarriageReturnProgressOutput_NormalizesOverwrittenLines test in DcpExecutorTests suite failed in the last CI run. Investigate and fix as appropriate |
Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/56825262-4c19-4588-a586-1f93ce482670 Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com>
Fixed in 8915099. The test was waiting for only 3 entries, but the certificate authority log can arrive before the 3 stdout records in CI, so the captured batch could miss the final Warning 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
…icrosoft#16796) * Preserve DCP log timestamps and normalize carriage returns Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/db6cb5cb-e08f-41ec-9cab-d1b240212f6e Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com> * Adjust carriage return regression assertion Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/db6cb5cb-e08f-41ec-9cab-d1b240212f6e Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com> * Preserve original raw log content Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/db6cb5cb-e08f-41ec-9cab-d1b240212f6e Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com> * Clarify log parsing helper names Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/db6cb5cb-e08f-41ec-9cab-d1b240212f6e Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com> * Remove raw content from resource log entries Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/3c9c7575-244c-44de-ab64-614b0f7e8973 Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com> * Handle lines that end with CR Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Track RawContent in ResourceLogEntry for [sys] entries to preserve timestamps in export path Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/8225b8c8-ec38-47af-b955-f82f15695d9d Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com> * Fix normalization ordering: try DCP parsing before CR normalization Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/7237c511-0243-48a5-b39e-7e33c098d724 Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com> * Add clarifying comment for targetLogCount in system log CR test Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/7237c511-0243-48a5-b39e-7e33c098d724 Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com> * Stabilize carriage return resource logging test Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/56825262-4c19-4588-a586-1f93ce482670 Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com> Co-authored-by: Karol Zadora-Przylecki <karolz@microsoft.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Description
Aspire was dropping DCP system log timestamps when formatting
[sys]messages, causing those entries to sort as timestamp-less console logs. Terminal-oriented output such as curl progress could also be split on standalone carriage returns, producing timestamp-less fragments in the dashboard.System log timestamps
ResourceLogSourceintoDcpResourceWatcher.[sys]formatting as content-only; ordering no longer depends on reparsing the formatted line.RawContentfield inResourceLogEntryfor DCP[sys]entries that includes the timestamp prefix, soLogEntry.RawContentretains timestamps in export/serialization paths (e.g. log archive export, dashboard export).Carriage-return normalization
ReadLineAsyncingestion with a reader that treats\n/\r\nas record terminators but preserves standalone\rlong enough to normalize terminal overwrite behavior.\rby returning the last meaningful segment before it rather than an empty string.ResourceLogEntrycarries normalized content, error state, timestamp metadata, and (for system logs) raw timestamped content for export; it does not preserve the raw pre-normalized log line.NormalizeCarriageReturnsafter DCP parsing to avoid corrupting the tab-delimited structure (timestamp\tlevel\tcategory\tmessage) before the parser sees it. For successfully parsed DCP lines, normalization is applied only to the extracted message content; for all other lines, the full raw line is normalized as before.Bug fixes
isErrormutation in the per-lineStreamLogsAsyncloop: uses a per-iteration local so that a line failing DCP parsing no longer inherits the error classification of the previous parsed line.Regression coverage
[sys]timestamp preservation and curl-like progress output.\r, verifying the entry retains the[sys]prefix and correct timestamp after the normalization-ordering fix.Example normalized input:
is ingested as one timestamped console log entry:
I have manually verified that the logs look good when changes in this PR are applied.
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: