Skip to content

Commit 5b98e76

Browse files
authored
fix(logs): wire up cli telemetry and model user errors (aws#1460)
* fix(logs): throw modeled exceptions * feat(cli): wire up logs telemetry
1 parent 3126905 commit 5b98e76

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/cli/commands/logs/command.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { COMMAND_DESCRIPTIONS } from '../../constants';
22
import { getErrorMessage } from '../../errors';
33
import { handleLogsEval } from '../../operations/eval';
44
import type { LogsEvalOptions } from '../../operations/eval';
5+
import { withCommandRunTelemetry } from '../../telemetry/cli-command-run.js';
56
import { requireProject } from '../../tui/guards';
67
import { handleLogs } from './action';
78
import type { LogsOptions } from './types';
@@ -31,7 +32,11 @@ export const registerLogs = (program: Command) => {
3132
requireProject();
3233

3334
try {
34-
const result = await handleLogs(cliOptions);
35+
const result = await withCommandRunTelemetry(
36+
'logs',
37+
{ has_query: !!cliOptions.query, has_level_filter: !!cliOptions.level },
38+
() => handleLogs(cliOptions)
39+
);
3540

3641
if (!result.success) {
3742
render(<Text color="red">{result.error.message}</Text>);
@@ -56,7 +61,9 @@ export const registerLogs = (program: Command) => {
5661
requireProject();
5762

5863
try {
59-
const result = await handleLogsEval(cliOptions);
64+
const result = await withCommandRunTelemetry('logs.evals', { has_follow: !!cliOptions.follow }, () =>
65+
handleLogsEval(cliOptions)
66+
);
6067

6168
if (!result.success) {
6269
render(<Text color="red">{result.error.message}</Text>);

src/cli/tui/screens/logs/useLogsFlow.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { toError } from '../../../../lib';
1+
import { ValidationError, toError } from '../../../../lib';
22
import type { AgentContext } from '../../../commands/logs/action';
33
import { resolveAgentContext } from '../../../commands/logs/action';
44
import { loadDeployedProjectConfig } from '../../../operations/resolve-agent';
@@ -40,7 +40,7 @@ export function useLogsFlow(): UseLogsFlowResult {
4040
const runtimeNames = context.project.runtimes.map(r => r.name);
4141

4242
if (runtimeNames.length === 0) {
43-
return { success: false as const, error: new Error('No runtimes defined in agentcore.json') };
43+
return { success: false as const, error: new ValidationError('No runtimes defined in agentcore.json') };
4444
}
4545

4646
const resolved: AgentContext[] = [];
@@ -54,7 +54,7 @@ export function useLogsFlow(): UseLogsFlowResult {
5454
if (resolved.length === 0) {
5555
return {
5656
success: false as const,
57-
error: new Error('No deployed agents found. Run `agentcore deploy` first.'),
57+
error: new ValidationError('No deployed agents found. Run `agentcore deploy` first.'),
5858
};
5959
}
6060

0 commit comments

Comments
 (0)