fix(traces): show Play Session Replay when rum_session_has_replay is the string "true" (#15222)

This commit is contained in:
Yechi Yang
2026-10-13 07:46:14 +00:00
committed by GitHub
parent 180daa0aa6
commit 1ae10ccbd4
2 changed files with 23 additions and 2 deletions
@@ -165,4 +165,21 @@ describe("resolveReplaySpan", () => {
];
expect(resolveReplaySpan(spans)).toBe(first);
});
// Span attributes ingested over OTLP come back from search as strings.
it('returns an ingested span whose replay flag is the string "true"', () => {
const native = {
span_id: "a1b2c3d4e5f60718",
rum_session_id: "sess-1",
rum_session_has_replay: "true",
};
expect(resolveReplaySpan([{ span_id: "s-0" }, native])).toBe(native);
});
it('returns null when an ingested replay flag is the string "false"', () => {
const spans = [
{ span_id: "a1b2c3d4e5f60718", rum_session_id: "sess-1", rum_session_has_replay: "false" },
];
expect(resolveReplaySpan(spans)).toBeNull();
});
});
+6 -2
View File
@@ -50,10 +50,14 @@ export function resolveSessionId(spans: any[] | null | undefined): string {
return s ? String(s.gen_ai_conversation_id || s.session_id || "") : "";
}
/** First RUM bridge span whose browser session has a replay to play; null when the trace has none. */
/** First span whose browser session has a replay to play; null when the trace has none. */
export function resolveReplaySpan(spans: any[] | null | undefined): any | null {
if (!spans?.length) return null;
return spans.find((sp: any) => sp?.rum_session_id && sp?.rum_session_has_replay === true) ?? null;
// RUM bridge spans carry a boolean; ingested span attributes come back from search as strings.
const hasReplay = (flag: unknown) => flag === true || flag === "true";
return (
spans.find((sp: any) => sp?.rum_session_id && hasReplay(sp?.rum_session_has_replay)) ?? null
);
}
/**