generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 8
feat: add agentcore traces command and trace link in invoke TUI
#493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d3123d6
feat: add `agentcore traces` command and trace link in invoke TUI
jesseturner21 94675e4
chore: remove --target option from traces commands
jesseturner21 064732c
fix: increase get-trace query timeout to 60s and add timeout detection
jesseturner21 a64a8fa
fix: increase list-traces query timeout to 60s
jesseturner21 5b44260
fix: show full trace ID and session ID in traces list output
jesseturner21 838c36b
refactor: extract shared agent resolution + add --since/--until to tr…
jesseturner21 2fed0ec
refactor: extract DEFAULT endpoint name to shared constant
jesseturner21 0d096e0
refactor: hoist traceUrl computation out of inline IIFE in InvokeScreen
jesseturner21 30a0340
fix: validate --limit is a number in traces list
jesseturner21 a50201d
fix: validate traceId format before interpolating into CWL query
jesseturner21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| import { parseTimeString } from '../../../lib/utils'; | ||
| import type { DeployedProjectConfig } from '../../operations/resolve-agent'; | ||
| import { resolveAgent } from '../../operations/resolve-agent'; | ||
| import { buildTraceConsoleUrl, getTrace, listTraces } from '../../operations/traces'; | ||
| import type { TracesGetOptions, TracesListOptions } from './types'; | ||
|
|
||
| export interface TracesListResult { | ||
| success: boolean; | ||
| agentName?: string; | ||
| targetName?: string; | ||
| consoleUrl?: string; | ||
| traces?: { traceId: string; timestamp: string; sessionId?: string }[]; | ||
| error?: string; | ||
| } | ||
|
|
||
| export async function handleTracesList( | ||
| context: DeployedProjectConfig, | ||
| options: TracesListOptions | ||
| ): Promise<TracesListResult> { | ||
| const resolved = resolveAgent(context, options); | ||
| if (!resolved.success) { | ||
| return { success: false, error: resolved.error }; | ||
| } | ||
|
|
||
| const { agent } = resolved; | ||
|
|
||
| const consoleUrl = buildTraceConsoleUrl({ | ||
| region: agent.region, | ||
| accountId: agent.accountId, | ||
| runtimeId: agent.runtimeId, | ||
| agentName: agent.agentName, | ||
| }); | ||
|
|
||
| const limit = options.limit ? parseInt(options.limit, 10) : 20; | ||
| if (isNaN(limit)) { | ||
| return { success: false, error: '--limit must be a number' }; | ||
| } | ||
|
|
||
| // Parse time options | ||
| let startTime: number | undefined; | ||
| let endTime: number | undefined; | ||
| if (options.since) { | ||
| startTime = parseTimeString(options.since); | ||
| } | ||
| if (options.until) { | ||
| endTime = parseTimeString(options.until); | ||
| } | ||
|
|
||
| const result = await listTraces({ | ||
| region: agent.region, | ||
| runtimeId: agent.runtimeId, | ||
| agentName: agent.agentName, | ||
| limit, | ||
| startTime, | ||
| endTime, | ||
| }); | ||
|
|
||
| if (!result.success) { | ||
| return { success: false, error: result.error, consoleUrl }; | ||
| } | ||
|
|
||
| return { | ||
| success: true, | ||
| agentName: agent.agentName, | ||
| targetName: agent.targetName, | ||
| consoleUrl, | ||
| traces: result.traces, | ||
| }; | ||
| } | ||
|
|
||
| export interface TracesGetResult { | ||
| success: boolean; | ||
| agentName?: string; | ||
| targetName?: string; | ||
| consoleUrl?: string; | ||
| filePath?: string; | ||
| error?: string; | ||
| } | ||
|
|
||
| export async function handleTracesGet( | ||
| context: DeployedProjectConfig, | ||
| traceId: string, | ||
| options: TracesGetOptions | ||
| ): Promise<TracesGetResult> { | ||
| const resolved = resolveAgent(context, options); | ||
| if (!resolved.success) { | ||
| return { success: false, error: resolved.error }; | ||
| } | ||
|
|
||
| const { agent } = resolved; | ||
|
|
||
| const consoleUrl = buildTraceConsoleUrl({ | ||
| region: agent.region, | ||
| accountId: agent.accountId, | ||
| runtimeId: agent.runtimeId, | ||
| agentName: agent.agentName, | ||
| }); | ||
|
|
||
| // Parse time options | ||
| let startTime: number | undefined; | ||
| let endTime: number | undefined; | ||
| if (options.since) { | ||
| startTime = parseTimeString(options.since); | ||
| } | ||
| if (options.until) { | ||
| endTime = parseTimeString(options.until); | ||
| } | ||
|
|
||
| const result = await getTrace({ | ||
| region: agent.region, | ||
| runtimeId: agent.runtimeId, | ||
| agentName: agent.agentName, | ||
| traceId, | ||
| outputPath: options.output, | ||
| startTime, | ||
| endTime, | ||
| }); | ||
|
|
||
| if (!result.success) { | ||
| return { success: false, error: result.error, consoleUrl }; | ||
| } | ||
|
|
||
| return { | ||
| success: true, | ||
| agentName: agent.agentName, | ||
| targetName: agent.targetName, | ||
| consoleUrl, | ||
| filePath: result.filePath, | ||
| }; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.