Merge pull request #1107 from pikasTech/issue-1106-otel-projection-summary
fix: show projection sync cursors in otel trace summary
This commit is contained in:
@@ -323,6 +323,7 @@ export function renderTraceTable(input: {
|
||||
const sessionMessageRows = traceSessionMessageRows(allSpans);
|
||||
const turnRows = traceTurnStatusRows(allSpans);
|
||||
const projectionRows = traceProjectionRows(allSpans);
|
||||
const projectionSyncRows = traceProjectionSyncRows(allSpans);
|
||||
const countRows = asArray(input.result.spanNameCounts).slice(0, 8).map((item) => {
|
||||
const row = asPlainRecord(item) ?? {};
|
||||
return [shortenEnd(textValue(row.name), 64), textValue(row.count)];
|
||||
@@ -368,6 +369,9 @@ export function renderTraceTable(input: {
|
||||
"Projection writes:",
|
||||
formatTable(["NAME", "TRACE", "SESSION", "TURN", "STATUS", "EVENT", "PROJECTED", "SOURCE", "MESSAGE"], projectionRows.length > 0 ? projectionRows : [["-", "-", "-", "-", "-", "-", "-", "-", "-"]]),
|
||||
"",
|
||||
"Projection sync cursors:",
|
||||
formatTable(["SERVICE", "TRACE", "SESSION", "AFTER", "END", "EVENTS", "RAW", "MAX", "LAST", "TERM"], projectionSyncRows.length > 0 ? projectionSyncRows : [["-", "-", "-", "-", "-", "-", "-", "-", "-", "-"]]),
|
||||
"",
|
||||
"Span name counts:",
|
||||
formatTable(["NAME", "COUNT"], countRows.length > 0 ? countRows : [["-", "-"]]),
|
||||
"",
|
||||
@@ -511,6 +515,25 @@ function traceProjectionRows(spans: Record<string, unknown>[]): string[][] {
|
||||
return dedupeRows(rows).slice(0, 12);
|
||||
}
|
||||
|
||||
function traceProjectionSyncRows(spans: Record<string, unknown>[]): string[][] {
|
||||
const rows = spans.filter((span) => textValue(span.name) === "projection_sync").map((span) => {
|
||||
const attrs = asPlainRecord(span.attributes);
|
||||
return [
|
||||
shortenEnd(textValue(span.service), 18),
|
||||
shortenMiddle(spanColumnAttr(attrs, ["traceId"]), 18),
|
||||
shortenMiddle(spanColumnAttr(attrs, ["sessionId"]), 18),
|
||||
shortenEnd(spanColumnAttr(attrs, ["afterSeq"]), 8),
|
||||
shortenEnd(spanColumnAttr(attrs, ["endSeq"]), 8),
|
||||
shortenEnd(spanColumnAttr(attrs, ["eventCount"]), 8),
|
||||
shortenEnd(spanColumnAttr(attrs, ["rawEventCount"]), 8),
|
||||
shortenEnd(spanColumnAttr(attrs, ["maxSeq"]), 8),
|
||||
shortenEnd(spanColumnAttr(attrs, ["traceLastSeq"]), 8),
|
||||
shortenEnd(spanColumnAttr(attrs, ["terminalFromEvents", "terminalFromRawEvents", "terminalStatus"]), 12),
|
||||
];
|
||||
});
|
||||
return dedupeRows(rows).slice(0, 16);
|
||||
}
|
||||
|
||||
function dedupeRows(rows: string[][]): string[][] {
|
||||
const output: string[][] = [];
|
||||
const seen = new Set<string>();
|
||||
|
||||
Reference in New Issue
Block a user