Repository navigation
fix(serviceevents): preserve map key order in mapToValue OTLP body - #1421
Conversation
mapToValue assembled each OTLP KeyValueList by iterating keys in reverse
(for i = keys.length-1 .. 0; map.put(keys[i], resultStack.pop())), so every
emitted map came out with its fields reversed. For incident snapshots this
made body.exception_info[0] serialize as
call_path -> stack_trace -> exception_message -> exception_type
instead of the builder's
exception_type -> exception_message -> stack_trace -> call_path,
and reversed the nested call_path entry fields too.
This diverges from the Python/JS serviceevents schema (forward order) and
from mapToValue's own ListMarker branch, which already preserves order. It
also breaks the App Signals incident-snapshot e2e: the exception cell asserts
an ordered regex ("exception_type":... then "function_name":...), which can
never match when exception_type is emitted last. (The latency cell anchors on
call_path, which happened to land first under reversal, so it passed --
masking the bug.)
Fix: pop children into a temp array in reverse index order, then insert
forward, mirroring ListMarker. Add a unit test pinning forward order for both
exception_info and its nested call_path entry.
Verified against live CloudWatch via the EC2 dev-loop: field order flips
forward and the incident-snapshot validator goes from FAIL to PASS (5/5).
|
Claude finished @vastin's task in 1m 26s —— View job Claude Code Review
SummaryThe fix is small, correct, and well-scoped. No blocking issues. Correctness of the fix ( Test coverage (
Nested-order verification is the important piece — it catches any future regression where the recursion/iteration is fixed at the top level but broken for children. Minor observations (non-blocking):
Nothing else to flag. LGTM. |
|
Claude finished @vastin's task in 57s —— View job Claude Code Review
SummaryNo new findings on this synchronize. The substantive diff hasn't changed since the prior review at 21:18Z — the new commit is a merge from
PR is already approved by @mxiamxia. Nothing further to flag. |
Issue #, if available: N/A
Description of changes:
ServiceEventsOtlpEmitter.mapToValuereversed the key order of every map itconverted to an OTLP
Value. The last child pushed on the result stack waspopped into the map first, so a source map ordered
exception_type -> exception_message -> stack_trace -> call_pathwas emitted ascall_path -> stack_trace -> exception_message -> exception_type.This makes the incident-snapshot
body.exception_infoserialize in reverse ofthe schema order shared with the Python and JS SDKs. CloudWatch delivers the log
bodyverbatim, so the reversed order reaches consumers and breaks the orderede2e assertion on
exception_info.Fix: pop the children into a temp array in reverse index order, then insert
forward — preserving the source map's insertion order. This mirrors the existing
ListMarkerbranch. Arrays were already order-correct; only maps were affected.Testing:
testEmitIncidentSnapshotPreservesExceptionInfoFieldOrder— aregression guard that fails on the old reversing code.
e2e cell flips from FAIL to PASS with only this change (5/5 cells pass).
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.