taist 0.1.12 → 0.1.13
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/lib/transform.js +5 -0
- package/package.json +1 -1
package/lib/transform.js
CHANGED
|
@@ -145,13 +145,16 @@ export function transformSource(source, moduleNameOrOptions, tracerImportPath) {
|
|
|
145
145
|
import { getGlobalReporter as __taist_getReporter } from "${reporterPath}";
|
|
146
146
|
import { getContext as __taist_getContext, runWithContext as __taist_runWithContext, generateId as __taist_generateId } from "${traceContextPath}";
|
|
147
147
|
const __taist_reporter = __taist_getReporter();
|
|
148
|
+
const __taist_debug = process.env.TAIST_DEBUG === 'true';
|
|
148
149
|
// Eagerly connect to collector if socket path is set (build-time instrumentation)
|
|
149
150
|
if (process.env.TAIST_COLLECTOR_SOCKET && !__taist_reporter.isConnected()) {
|
|
150
151
|
__taist_reporter.connectEager();
|
|
151
152
|
}
|
|
152
153
|
const __taist_wrap = (fn, name) => {
|
|
153
154
|
if (typeof fn !== 'function') return fn;
|
|
155
|
+
if (__taist_debug) console.log('[taist] wrapping:', name);
|
|
154
156
|
const wrapped = function(...args) {
|
|
157
|
+
if (__taist_debug) console.log('[taist] CALLED:', name);
|
|
155
158
|
const parentCtx = __taist_getContext();
|
|
156
159
|
const id = __taist_generateId();
|
|
157
160
|
const depth = parentCtx.depth;
|
|
@@ -218,10 +221,12 @@ const __taist_instrumentClass = (cls, name) => {
|
|
|
218
221
|
};
|
|
219
222
|
const __taist_instrumentObject = (obj, name, visited = new WeakSet()) => {
|
|
220
223
|
if (!obj || typeof obj !== 'object' || visited.has(obj)) return obj;
|
|
224
|
+
if (__taist_debug) console.log('[taist] instrumentObject:', name, Object.keys(obj));
|
|
221
225
|
visited.add(obj);
|
|
222
226
|
for (const key of Object.keys(obj)) {
|
|
223
227
|
const value = obj[key];
|
|
224
228
|
if (typeof value === 'function') {
|
|
229
|
+
if (__taist_debug) console.log('[taist] found method:', name + '.' + key);
|
|
225
230
|
obj[key] = __taist_wrap(value, name + '.' + key);
|
|
226
231
|
} else if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
227
232
|
__taist_instrumentObject(value, name + '.' + key, visited);
|