MCPcopy Index your code
hub / github.com/codeaashu/claude-code / withDiagnosticsTiming

Function withDiagnosticsTiming

src/utils/diagLogs.ts:72–94  ·  view source on GitHub ↗
(
  event: string,
  fn: () => Promise<T>,
  getData?: (result: T) => Record<string, unknown>,
)

Source from the content-addressed store, hash-verified

70 * @returns The result of the wrapped function
71 */
72export async function withDiagnosticsTiming<T>(
73 event: string,
74 fn: () => Promise<T>,
75 getData?: (result: T) => Record<string, unknown>,
76): Promise<T> {
77 const startTime = Date.now()
78 logForDiagnosticsNoPII('info', `${event}_started`)
79
80 try {
81 const result = await fn()
82 const additionalData = getData ? getData(result) : {}
83 logForDiagnosticsNoPII('info', `${event}_completed`, {
84 duration_ms: Date.now() - startTime,
85 ...additionalData,
86 })
87 return result
88 } catch (error) {
89 logForDiagnosticsNoPII('error', `${event}_failed`, {
90 duration_ms: Date.now() - startTime,
91 })
92 throw error
93 }
94}
95

Calls 1

logForDiagnosticsNoPIIFunction · 0.85

Tested by

no test coverage detected