Execute a function within a new span. Automatically handles errors and sets span status.
Name of the span
Function to execute within the span
Span options
The result of the function
const result = await withSpan('processRequest', async (span) => { span.setAttribute('request.id', requestId); return await processRequest();}); Copy
const result = await withSpan('processRequest', async (span) => { span.setAttribute('request.id', requestId); return await processRequest();});
Execute a function within a new span. Automatically handles errors and sets span status.