diff --git a/web/src/plugins/traces/traceDetails.utils.spec.ts b/web/src/plugins/traces/traceDetails.utils.spec.ts index 94d201f211..b91d55abed 100644 --- a/web/src/plugins/traces/traceDetails.utils.spec.ts +++ b/web/src/plugins/traces/traceDetails.utils.spec.ts @@ -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(); + }); }); diff --git a/web/src/plugins/traces/traceDetails.utils.ts b/web/src/plugins/traces/traceDetails.utils.ts index 46ac780a58..b67942677c 100644 --- a/web/src/plugins/traces/traceDetails.utils.ts +++ b/web/src/plugins/traces/traceDetails.utils.ts @@ -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 + ); } /**