Connectum API Reference / @connectum/otel / traced / traced
Function: traced() ​
traced<
T>(fn,options?):T
Defined in: packages/otel/src/traced.ts:31
Wraps a function in an OpenTelemetry span.
The wrapper preserves the original function's type signature. Supports both sync and async functions.
Type Parameters ​
T ​
T extends (...args) => any
Parameters ​
fn ​
T
The function to wrap
options? ​
Tracing options
Returns ​
T
Wrapped function with the same type signature
Example ​
typescript
const findUser = traced(async (id: string) => {
return await db.users.findById(id);
}, { name: "UserService.findUser" });