fix(observability): order TRA logs by request time + monotonic sequence (SDK-6164)#55
Closed
harshit-browserstack wants to merge 1 commit into
Closed
Conversation
SDK-6164: logs reach Test Observability but the Logs tab renders them out of order because the backend sorts by the event timestamp. - createHttpLogEvent stamped HTTP logs with the response-received time (httpResponse[0]), so a slow request sorted after logs emitted while it was in flight. Stamp with the request-issued time (httpRequest[0]) instead; duration_ms is still measured request->response. - No LogCreated event carried a tiebreaker, so same-millisecond logs had a non-deterministic order. Add a per-process monotonic `sequence` (new src/utils/logSequence.js) to every log event (TEST_LOG, HTTP, TEST_SCREENSHOT) so the backend can sort by (timestamp, sequence). Adds test/src/test-observability/logOrdering.js (4 cases) covering both. Note: the `sequence` tiebreaker is inert until the TRA backend adds it as a secondary sort key — tracked as a cross-team follow-up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
Closing — this targeted the public upstream by mistake. Re-opening within the BrowserStack fork. |
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.
SDK-6164 — TRA log timestamp ordering
Problem. Logs reach Test Observability but the Logs tab renders them out of order. The backend orders log events by their
timestamp, and two emitters produced timestamps that didn't reflect emission order:createHttpLogEventstamped HTTP logs with the response-received time (httpResponse[0]). A slow request therefore sorted after logs that were emitted while it was still in flight.LogCreatedevent carried a tiebreaker, so logs sharing the same millisecond had a non-deterministic order.Fix.
httpRequest[0]).duration_msis still measured request→response, so no metric regresses.sequence(newsrc/utils/logSequence.js) to everyLogCreatedevent (TEST_LOG,HTTP,TEST_SCREENSHOT) so the backend can sort by(timestamp, sequence).Verification. A standalone emission-boundary repro (stubbing
helper.uploadEventData) shows the server-sorted(timestamp, sequence)order now equals emission order —inversion=false, tie=false. Addedtest/src/test-observability/logOrdering.js(4 cases) covering request-time stamping, post-sort ordering, same-ms tiebreaking, and the shared cross-kind sequence. All pass; eslint clean.🤖 Generated with Claude Code