RuntimeGetProfilerTraceData
Retrieve profiler trace data by trace ID or URI, returning parsed JSON for hitlist, statements, or database accesses.
Instructions
[runtime] Read profiler trace data by trace id/uri: hitlist, statements, or db accesses. Returns parsed JSON payload.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| trace_id_or_uri | Yes | Profiler trace ID or full ADT trace URI. | |
| view | Yes | Trace view to retrieve. | |
| with_system_events | No | Include system events. | |
| id | No | Statement node ID (for statements view). | |
| with_details | No | Include statement details (for statements view). | |
| auto_drill_down_threshold | No | Auto drill-down threshold (for statements view). |
Implementation Reference
- Main handler function that reads profiler trace data from an ADT system. Uses AdtRuntimeClient to fetch hitlist, statements, or db_accesses views based on args.view. Returns parsed JSON payload via return_response.
export async function handleRuntimeGetProfilerTraceData( context: HandlerContext, args: RuntimeGetProfilerTraceDataArgs, ) { const { connection, logger } = context; try { if (!args?.trace_id_or_uri) { throw new Error('Parameter "trace_id_or_uri" is required'); } const runtimeClient = new AdtRuntimeClient(connection, logger); const profiler = runtimeClient.getProfiler(); const response = args.view === 'hitlist' ? await profiler.getHitList(args.trace_id_or_uri, { withSystemEvents: args.with_system_events, }) : args.view === 'statements' ? await profiler.getStatements(args.trace_id_or_uri, { id: args.id, withDetails: args.with_details, autoDrillDownThreshold: args.auto_drill_down_threshold, withSystemEvents: args.with_system_events, }) : await profiler.getDbAccesses(args.trace_id_or_uri, { withSystemEvents: args.with_system_events, }); return return_response({ data: JSON.stringify( { success: true, view: args.view, trace_id_or_uri: args.trace_id_or_uri, status: response.status, payload: parseRuntimePayloadToJson(response.data), }, null, 2, ), status: response.status, statusText: response.statusText, headers: response.headers, config: response.config, }); } catch (error: any) { logger?.error('Error reading profiler trace data:', error); return return_error(error); } } - TypeScript interface defining the input args for the tool: trace_id_or_uri, view (hitlist|statements|db_accesses), and optional parameters like with_system_events, id, with_details, auto_drill_down_threshold.
interface RuntimeGetProfilerTraceDataArgs { trace_id_or_uri: string; view: 'hitlist' | 'statements' | 'db_accesses'; with_system_events?: boolean; id?: number; with_details?: boolean; auto_drill_down_threshold?: number; } - TOOL_DEFINITION constant exporting the tool name 'RuntimeGetProfilerTraceData', availability (onprem/cloud), description, and JSON Schema input schema with properties like trace_id_or_uri, view, with_system_events, id, with_details, auto_drill_down_threshold.
export const TOOL_DEFINITION = { name: 'RuntimeGetProfilerTraceData', available_in: ['onprem', 'cloud'] as const, description: '[runtime] Read profiler trace data by trace id/uri: hitlist, statements, or db accesses. Returns parsed JSON payload.', inputSchema: { type: 'object', properties: { trace_id_or_uri: { type: 'string', description: 'Profiler trace ID or full ADT trace URI.', }, view: { type: 'string', enum: ['hitlist', 'statements', 'db_accesses'], description: 'Trace view to retrieve.', }, with_system_events: { type: 'boolean', description: 'Include system events.', }, id: { type: 'number', description: 'Statement node ID (for statements view).', }, with_details: { type: 'boolean', description: 'Include statement details (for statements view).', }, auto_drill_down_threshold: { type: 'number', description: 'Auto drill-down threshold (for statements view).', }, }, required: ['trace_id_or_uri', 'view'], }, } as const; - src/lib/handlers/groups/SystemHandlersGroup.ts:141-145 (registration)Handler entry in SystemHandlersGroup that maps RuntimeGetProfilerTraceData_Tool to handleRuntimeGetProfilerTraceData(this.context, args).
{ toolDefinition: RuntimeGetProfilerTraceData_Tool, handler: (args: any) => handleRuntimeGetProfilerTraceData(this.context, args), }, - Compact handler 'HandlerProfileView' that delegates to handleRuntimeGetProfilerTraceData, reusing the same logic.
export async function handleHandlerProfileView( context: HandlerContext, args: HandlerProfileViewArgs, ) { return handleRuntimeGetProfilerTraceData(context, args); }