taist 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/instrument.js +3 -1
- package/package.json +1 -1
- package/types/instrument.d.ts +22 -0
package/instrument.js
CHANGED
|
@@ -46,7 +46,8 @@ import {
|
|
|
46
46
|
instrumentDirectory,
|
|
47
47
|
instrumentModules,
|
|
48
48
|
wrapWithContext,
|
|
49
|
-
instrumentClassWithContext
|
|
49
|
+
instrumentClassWithContext,
|
|
50
|
+
instrumentModule
|
|
50
51
|
} from './lib/instrument-all.js';
|
|
51
52
|
|
|
52
53
|
// Initialize global reporter for cross-process trace collection
|
|
@@ -277,6 +278,7 @@ export {
|
|
|
277
278
|
instrumentAll,
|
|
278
279
|
instrumentDirectory,
|
|
279
280
|
instrumentModules,
|
|
281
|
+
instrumentModule,
|
|
280
282
|
wrapWithContext,
|
|
281
283
|
startTrace,
|
|
282
284
|
getContext,
|
package/package.json
CHANGED
package/types/instrument.d.ts
CHANGED
|
@@ -199,6 +199,28 @@ export declare function instrumentModules(
|
|
|
199
199
|
options?: InstrumentAllOptions
|
|
200
200
|
): Promise<Record<string, unknown>>;
|
|
201
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Instrument all exports from a module object
|
|
204
|
+
*
|
|
205
|
+
* Wraps all function exports with context-aware tracing.
|
|
206
|
+
* Classes are wrapped so new instances are automatically instrumented.
|
|
207
|
+
*
|
|
208
|
+
* @param moduleExports Module exports object (e.g., from `import * as mod from './mod.js'`)
|
|
209
|
+
* @param moduleName Module name prefix for trace names
|
|
210
|
+
* @returns Object with same keys but instrumented values
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* import { instrumentModule } from 'taist/instrument';
|
|
214
|
+
* import * as orderServices from './services/order.js';
|
|
215
|
+
*
|
|
216
|
+
* export const Order = instrumentModule(orderServices, 'Order');
|
|
217
|
+
* // All functions in Order will now be traced
|
|
218
|
+
*/
|
|
219
|
+
export declare function instrumentModule<T extends Record<string, unknown>>(
|
|
220
|
+
moduleExports: T,
|
|
221
|
+
moduleName: string
|
|
222
|
+
): T;
|
|
223
|
+
|
|
202
224
|
/**
|
|
203
225
|
* Wrap a function with trace context
|
|
204
226
|
* @param fn Function to wrap
|