mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-04 16:09:05 +00:00
fix(traces): show Play Session Replay when rum_session_has_replay is the string "true" (#15222)
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user