Skip to content

Commit e6727e1

Browse files
committed
fix: adapt span commands to yield-based output system from main
After merging main, command.ts uses async generators + CommandOutput class: - Remove 'json: true' from OutputConfig (no longer needed on main) - Change async func → async *func (generator) - Replace return { data, hint } → yield new CommandOutput(data) + return { hint } - Import CommandOutput from formatters/output.js
1 parent 70895de commit e6727e1

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/commands/span/list.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
} from "../../lib/formatters/index.js";
2222
import { filterFields } from "../../lib/formatters/json.js";
2323
import { renderMarkdown } from "../../lib/formatters/markdown.js";
24+
import { CommandOutput } from "../../lib/formatters/output.js";
2425
import {
2526
applyFreshFlag,
2627
FRESH_ALIASES,
@@ -182,7 +183,6 @@ export const listCommand = buildCommand({
182183
' sentry span list <trace-id> -q "duration:>100ms" # Spans slower than 100ms',
183184
},
184185
output: {
185-
json: true,
186186
human: formatSpanListHuman,
187187
jsonTransform: jsonTransformSpanList,
188188
},
@@ -225,7 +225,7 @@ export const listCommand = buildCommand({
225225
s: "sort",
226226
},
227227
},
228-
async func(this: SentryContext, flags: ListFlags, ...args: string[]) {
228+
async *func(this: SentryContext, flags: ListFlags, ...args: string[]) {
229229
applyFreshFlag(flags);
230230
const { cwd, setContext } = this;
231231
const log = logger.withTag("span.list");
@@ -304,6 +304,7 @@ export const listCommand = buildCommand({
304304
: `${countText} Use 'sentry span view <span-id> --trace ${traceId}' to view span details.`;
305305
}
306306

307-
return { data: { flatSpans, hasMore, traceId }, hint };
307+
yield new CommandOutput({ flatSpans, hasMore, traceId });
308+
return { hint };
308309
},
309310
});

src/commands/span/view.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
formatSpanDetails,
2121
} from "../../lib/formatters/index.js";
2222
import { filterFields } from "../../lib/formatters/json.js";
23+
import { CommandOutput } from "../../lib/formatters/output.js";
2324
import {
2425
applyFreshFlag,
2526
FRESH_ALIASES,
@@ -295,7 +296,6 @@ export const viewCommand = buildCommand({
295296
" sentry span view a1b2c3d4e5f67890 b2c3d4e5f6789012 --trace <trace-id>",
296297
},
297298
output: {
298-
json: true,
299299
human: formatSpanViewHuman,
300300
jsonTransform: jsonTransformSpanView,
301301
},
@@ -320,7 +320,7 @@ export const viewCommand = buildCommand({
320320
},
321321
aliases: { ...FRESH_ALIASES, t: "trace" },
322322
},
323-
async func(this: SentryContext, flags: ViewFlags, ...args: string[]) {
323+
async *func(this: SentryContext, flags: ViewFlags, ...args: string[]) {
324324
applyFreshFlag(flags);
325325
const { cwd, setContext } = this;
326326
const cmdLog = logger.withTag("span.view");
@@ -381,8 +381,6 @@ export const viewCommand = buildCommand({
381381

382382
warnMissingIds(spanIds, foundIds);
383383

384-
return {
385-
data: { results, traceId, spansDepth: flags.spans },
386-
};
384+
yield new CommandOutput({ results, traceId, spansDepth: flags.spans });
387385
},
388386
});

0 commit comments

Comments
 (0)