( options: DiagnosticsScopeOptions, fn: () => Promise<T> | T, )
| 50 | } |
| 51 | |
| 52 | export async function withDiagnosticsScope<T>( |
| 53 | options: DiagnosticsScopeOptions, |
| 54 | fn: () => Promise<T> | T, |
| 55 | ): Promise<T> { |
| 56 | const scope: DiagnosticsScope = { |
| 57 | ...options, |
| 58 | diagnosticId: createDiagnosticId(), |
| 59 | events: [], |
| 60 | liveWrittenEventCount: 0, |
| 61 | phaseCounts: new Map(), |
| 62 | }; |
| 63 | return await diagnosticsStorage.run(scope, fn); |
| 64 | } |
| 65 | |
| 66 | export function updateDiagnosticsScope(options: DiagnosticsScopeOptions): void { |
| 67 | const scope = diagnosticsStorage.getStore(); |