repro-nest 0.0.216 → 0.0.217
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/docs/tracing.md +1 -1
- package/package.json +1 -1
- package/tracer/runtime.js +47 -18
package/docs/tracing.md
CHANGED
|
@@ -51,7 +51,7 @@ captured in the session payload.
|
|
|
51
51
|
| --------------- | ------------------------------------------------------------------------------------------------- |
|
|
52
52
|
| `fn`/`functionName` | Match against the instrumented function name (substring or RegExp). |
|
|
53
53
|
| `wrapper`/`wrapperClass`/`className`/`owner` | Match the wrapper/owner inferred from the function name (e.g. `"UserService"` in `"UserService.create"`). |
|
|
54
|
-
| `file` | Match the filename reported by the trace event (callsite
|
|
54
|
+
| `file` | Match the filename reported by the trace event (callsite when available; may fall back to the function definition file when the caller is not instrumented). |
|
|
55
55
|
| `line` | Match the line number reported by the trace event. |
|
|
56
56
|
| `lib`/`library` | Match the npm package inferred from the file path (e.g. `"mongoose"`). |
|
|
57
57
|
| `type`/`functionType` | Match the detected function kind (e.g. `"constructor"`, `"method"`, `"arrow"`). |
|
package/package.json
CHANGED
package/tracer/runtime.js
CHANGED
|
@@ -86,15 +86,15 @@ function pushSpan(ctx, depth, explicitParentId = null) {
|
|
|
86
86
|
const parent = explicitParentId !== null && explicitParentId !== undefined
|
|
87
87
|
? { id: explicitParentId, parentId: null }
|
|
88
88
|
: (stack.length ? stack[stack.length - 1] : null);
|
|
89
|
-
const span = { id: ++SPAN_COUNTER, parentId: parent ? parent.id : null, depth };
|
|
89
|
+
const span = { id: ++SPAN_COUNTER, parentId: parent ? parent.id : null, depth, file: null, line: null, sourceFile: null };
|
|
90
90
|
stack.push(span);
|
|
91
91
|
return span;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
function popSpan(ctx) {
|
|
95
95
|
const stack = ctx.__repro_span_stack;
|
|
96
|
-
if (!Array.isArray(stack) || !stack.length) return { id: null, parentId: null, depth: null };
|
|
97
|
-
return stack.pop() || { id: null, parentId: null, depth: null };
|
|
96
|
+
if (!Array.isArray(stack) || !stack.length) return { id: null, parentId: null, depth: null, file: null, line: null, sourceFile: null };
|
|
97
|
+
return stack.pop() || { id: null, parentId: null, depth: null, file: null, line: null, sourceFile: null };
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
const trace = {
|
|
@@ -120,15 +120,36 @@ const trace = {
|
|
|
120
120
|
}
|
|
121
121
|
frameStack.push(frameUnawaited);
|
|
122
122
|
|
|
123
|
+
const fallbackDefinitionFile = meta?.file || null;
|
|
124
|
+
let file = meta?.file || null;
|
|
125
|
+
let line = meta?.line || null;
|
|
126
|
+
let sourceFile = meta?.sourceFile || null;
|
|
127
|
+
try {
|
|
128
|
+
const queue = ctx.__repro_callsite_queue;
|
|
129
|
+
if (Array.isArray(queue) && queue.length) {
|
|
130
|
+
const override = queue.shift();
|
|
131
|
+
if (override && (override.file || override.line !== null && override.line !== undefined)) {
|
|
132
|
+
if (!sourceFile && fallbackDefinitionFile) sourceFile = fallbackDefinitionFile;
|
|
133
|
+
if (override.file) file = override.file;
|
|
134
|
+
if (override.line !== null && override.line !== undefined) line = override.line;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
} catch {}
|
|
138
|
+
|
|
123
139
|
const span = pushSpan(ctx, ctx.depth, parentSpanIdOverride);
|
|
140
|
+
try {
|
|
141
|
+
span.file = file;
|
|
142
|
+
span.line = line;
|
|
143
|
+
span.sourceFile = sourceFile;
|
|
144
|
+
} catch {}
|
|
124
145
|
|
|
125
146
|
emit({
|
|
126
147
|
type: 'enter',
|
|
127
148
|
t: Date.now(),
|
|
128
149
|
fn,
|
|
129
|
-
file
|
|
130
|
-
line
|
|
131
|
-
sourceFile
|
|
150
|
+
file,
|
|
151
|
+
line,
|
|
152
|
+
sourceFile,
|
|
132
153
|
functionType: meta?.functionType || null,
|
|
133
154
|
traceId: ctx.traceId,
|
|
134
155
|
depth: ctx.depth,
|
|
@@ -155,7 +176,7 @@ const trace = {
|
|
|
155
176
|
const spanStackRef = Array.isArray(ctx.__repro_span_stack) ? ctx.__repro_span_stack : [];
|
|
156
177
|
const spanInfoPeek = spanStackRef.length
|
|
157
178
|
? spanStackRef[spanStackRef.length - 1]
|
|
158
|
-
: { id: null, parentId: null, depth: depthAtExit };
|
|
179
|
+
: { id: null, parentId: null, depth: depthAtExit, file: baseMeta.file, line: baseMeta.line, sourceFile: baseMeta.sourceFile };
|
|
159
180
|
const baseDetail = {
|
|
160
181
|
args: detail?.args,
|
|
161
182
|
returnValue: detail?.returnValue,
|
|
@@ -190,9 +211,9 @@ const trace = {
|
|
|
190
211
|
type: 'exit',
|
|
191
212
|
t: Date.now(),
|
|
192
213
|
fn: baseMeta.fn,
|
|
193
|
-
file: baseMeta.file,
|
|
194
|
-
line: baseMeta.line,
|
|
195
|
-
sourceFile: baseMeta.sourceFile,
|
|
214
|
+
file: spanInfo.file !== null && spanInfo.file !== undefined ? spanInfo.file : baseMeta.file,
|
|
215
|
+
line: spanInfo.line !== null && spanInfo.line !== undefined ? spanInfo.line : baseMeta.line,
|
|
216
|
+
sourceFile: spanInfo.sourceFile !== null && spanInfo.sourceFile !== undefined ? spanInfo.sourceFile : baseMeta.sourceFile,
|
|
196
217
|
functionType: baseMeta.functionType || null,
|
|
197
218
|
traceId: traceIdAtExit,
|
|
198
219
|
depth: spanInfo.depth ?? depthAtExit,
|
|
@@ -720,14 +741,22 @@ if (!global.__repro_call) {
|
|
|
720
741
|
const isolatedStore = isUnawaitedCall
|
|
721
742
|
? (forkAlsStoreForUnawaited(callStoreForArgs || ctx) || cloneStore(callStoreForArgs || ctx))
|
|
722
743
|
: null;
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
744
|
+
try {
|
|
745
|
+
const shouldWrap = !isAsyncLocalContextSetter(fn, thisArg);
|
|
746
|
+
const argsForCall = shouldWrap ? wrapArgsWithStore(args, callStoreForArgs || ctx) : args;
|
|
747
|
+
const normalizedCallFile = callFile ? String(callFile).trim() : '';
|
|
748
|
+
const callsiteFile = normalizedCallFile ? normalizedCallFile : null;
|
|
749
|
+
const callsiteLine = Number.isFinite(Number(callLine)) && Number(callLine) > 0 ? Number(callLine) : null;
|
|
750
|
+
const callsiteStore = isolatedStore || ctx;
|
|
751
|
+
if (callsiteStore && (callsiteFile || callsiteLine !== null)) {
|
|
752
|
+
const queue = callsiteStore.__repro_callsite_queue || (callsiteStore.__repro_callsite_queue = []);
|
|
753
|
+
queue.push({ file: callsiteFile, line: callsiteLine });
|
|
754
|
+
}
|
|
755
|
+
let out;
|
|
756
|
+
if (isolatedStore) {
|
|
757
|
+
als.run(isolatedStore, () => {
|
|
758
|
+
out = fn.apply(thisArg, argsForCall);
|
|
759
|
+
});
|
|
731
760
|
} else {
|
|
732
761
|
out = fn.apply(thisArg, argsForCall);
|
|
733
762
|
}
|