repro-nest 0.0.212 → 0.0.213
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/dist/index.js +20 -0
- package/package.json +1 -1
- package/src/index.ts +21 -0
package/dist/index.js
CHANGED
|
@@ -491,6 +491,26 @@ function isReproTracingEnabled() { return __TRACER_READY; }
|
|
|
491
491
|
exports.isReproTracingEnabled = isReproTracingEnabled;
|
|
492
492
|
function captureSpanContextFromTracer(source) {
|
|
493
493
|
try {
|
|
494
|
+
// Prefer a preserved store captured at the call-site for thenables (e.g., Mongoose Query),
|
|
495
|
+
// because the tracer intentionally detaches spans before the query is actually executed.
|
|
496
|
+
const promiseStore = source && source[Symbol.for('__repro_promise_store')];
|
|
497
|
+
if (promiseStore) {
|
|
498
|
+
const stack = Array.isArray(promiseStore.__repro_span_stack) ? promiseStore.__repro_span_stack : [];
|
|
499
|
+
const top = stack.length ? stack[stack.length - 1] : null;
|
|
500
|
+
const spanId = top && top.id != null ? top.id : null;
|
|
501
|
+
const parentSpanId = top && top.parentId != null
|
|
502
|
+
? top.parentId
|
|
503
|
+
: (stack.length >= 2 ? (stack[stack.length - 2]?.id ?? null) : null);
|
|
504
|
+
const depth = top && top.depth != null
|
|
505
|
+
? top.depth
|
|
506
|
+
: (typeof promiseStore.depth === 'number'
|
|
507
|
+
? promiseStore.depth
|
|
508
|
+
: (stack.length ? stack.length : null));
|
|
509
|
+
const traceId = promiseStore.traceId ?? null;
|
|
510
|
+
if (traceId || spanId !== null || parentSpanId !== null) {
|
|
511
|
+
return { traceId, spanId, parentSpanId, depth: depth == null ? null : depth };
|
|
512
|
+
}
|
|
513
|
+
}
|
|
494
514
|
const fromSource = source && source.__repro_span_context;
|
|
495
515
|
if (fromSource) {
|
|
496
516
|
return {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -684,6 +684,27 @@ export function isReproTracingEnabled() { return __TRACER_READY; }
|
|
|
684
684
|
|
|
685
685
|
function captureSpanContextFromTracer(source?: any): SpanContext | null {
|
|
686
686
|
try {
|
|
687
|
+
// Prefer a preserved store captured at the call-site for thenables (e.g., Mongoose Query),
|
|
688
|
+
// because the tracer intentionally detaches spans before the query is actually executed.
|
|
689
|
+
const promiseStore = source && source[Symbol.for('__repro_promise_store')];
|
|
690
|
+
if (promiseStore) {
|
|
691
|
+
const stack = Array.isArray(promiseStore.__repro_span_stack) ? promiseStore.__repro_span_stack : [];
|
|
692
|
+
const top = stack.length ? stack[stack.length - 1] : null;
|
|
693
|
+
const spanId = top && top.id != null ? top.id : null;
|
|
694
|
+
const parentSpanId = top && top.parentId != null
|
|
695
|
+
? top.parentId
|
|
696
|
+
: (stack.length >= 2 ? (stack[stack.length - 2]?.id ?? null) : null);
|
|
697
|
+
const depth = top && top.depth != null
|
|
698
|
+
? top.depth
|
|
699
|
+
: (typeof promiseStore.depth === 'number'
|
|
700
|
+
? promiseStore.depth
|
|
701
|
+
: (stack.length ? stack.length : null));
|
|
702
|
+
const traceId = promiseStore.traceId ?? null;
|
|
703
|
+
if (traceId || spanId !== null || parentSpanId !== null) {
|
|
704
|
+
return { traceId, spanId, parentSpanId, depth: depth == null ? null : depth };
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
687
708
|
const fromSource = source && source.__repro_span_context;
|
|
688
709
|
if (fromSource) {
|
|
689
710
|
return {
|