@mastra/observability 1.18.4 → 1.19.0-alpha.1
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/context/metrics.d.ts.map +1 -1
- package/dist/exporters/tracking.d.ts +7 -0
- package/dist/exporters/tracking.d.ts.map +1 -1
- package/dist/index.cjs +90 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +90 -24
- package/dist/index.js.map +1 -1
- package/dist/instances/base.d.ts.map +1 -1
- package/dist/metrics/auto-extract.d.ts.map +1 -1
- package/dist/spans/base.d.ts +1 -1
- package/dist/spans/base.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/context/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,OAAO,EACP,KAAK,EACL,SAAS,EACT,kBAAkB,EAIlB,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAE/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,uDAAuD;AACvD,MAAM,WAAW,oBAAoB;IACnC,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,kEAAkE;IAClE,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAExC,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC,0DAA0D;IAC1D,iBAAiB,EAAE,iBAAiB,CAAC;IAErC,6BAA6B;IAC7B,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAED;;;GAGG;AACH,qBAAa,kBAAmB,YAAW,cAAc;IACvD,OAAO,CAAC,OAAO,C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AS;IACzB,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,kBAAkB,CAAC,CAAqB;IAChD,OAAO,CAAC,QAAQ,CAAC,CAA0B;IAC3C,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,gBAAgB,CAAmB;IAE3C;;;OAGG;IACH,YAAY,MAAM,EAAE,oBAAoB,EAOvC;IAED,iCAAiC;IACjC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAwBpG;IAED,wCAAwC;IACxC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM7B;IAED,wCAAwC;IACxC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAMzB;IAED,wCAAwC;IACxC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAMjC;CACF"}
|
|
@@ -149,6 +149,10 @@ export declare class TraceData<TRootData, TSpanData, TEventData, TMetadata> {
|
|
|
149
149
|
clearWaitingFor(args: {
|
|
150
150
|
spanId: string;
|
|
151
151
|
}): void;
|
|
152
|
+
/**
|
|
153
|
+
* Get the span IDs that have events waiting on them.
|
|
154
|
+
*/
|
|
155
|
+
getWaitingForSpanIds(): string[];
|
|
152
156
|
/**
|
|
153
157
|
* Get total count of events in all waiting queues.
|
|
154
158
|
*/
|
|
@@ -448,6 +452,9 @@ export declare abstract class TrackingExporter<TRootData, TSpanData, TEventData,
|
|
|
448
452
|
* This is useful in serverless environments where you need to ensure spans
|
|
449
453
|
* are exported before the runtime instance is terminated.
|
|
450
454
|
*
|
|
455
|
+
* Queued events whose dependencies have been built are processed first, so
|
|
456
|
+
* a shutdown() right after flush() only aborts spans that are still open.
|
|
457
|
+
*
|
|
451
458
|
* Subclasses should override _flush() to implement vendor-specific flush logic.
|
|
452
459
|
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,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,CAAC,CAoBzD;IAED;;;OAGG;IACH,SAAS,CAAC,YAAY,IAAI,MAAM,CAE/B;IAMD;;;;;;OAMG;IACH,UAAgB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAG;IAE1C;;;;;;;;;OASG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAU3B;IAED;;;OAGG;IACH,UAAgB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAG;IAEhD;;;OAGG;IACH,UAAgB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAG;IAEjD;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAoD9B;CACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -1066,6 +1066,7 @@ var MetricsContextImpl = class {
|
|
|
1066
1066
|
labels: filteredLabels,
|
|
1067
1067
|
correlationContext: this.correlationContext,
|
|
1068
1068
|
costContext,
|
|
1069
|
+
...options?.usageId ? { usageId: options.usageId } : {},
|
|
1069
1070
|
metadata: this.metadata
|
|
1070
1071
|
}
|
|
1071
1072
|
};
|
|
@@ -1767,13 +1768,13 @@ function emitUsageMetrics(attrs, usage, metrics) {
|
|
|
1767
1768
|
metricCosts = /* @__PURE__ */ new Map();
|
|
1768
1769
|
}
|
|
1769
1770
|
const labels = attrs.usageIncomplete ? { usageIncomplete: "true" } : void 0;
|
|
1771
|
+
const usageId = generateSignalId();
|
|
1770
1772
|
const emit = (name, value) => {
|
|
1771
1773
|
const costContext = metricCosts.get(name);
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
}
|
|
1776
|
-
metrics.emit(name, value, labels, { costContext });
|
|
1774
|
+
metrics.emit(name, value, labels, costContext ? {
|
|
1775
|
+
costContext,
|
|
1776
|
+
usageId
|
|
1777
|
+
} : { usageId });
|
|
1777
1778
|
};
|
|
1778
1779
|
for (const sample of getTokenMetricSamples(usage)) emit(sample.name, sample.value);
|
|
1779
1780
|
}
|
|
@@ -3204,6 +3205,7 @@ var BaseSpan = class BaseSpan {
|
|
|
3204
3205
|
exportSpan(includeInternalSpans) {
|
|
3205
3206
|
const hideInput = this.traceState?.hideInput ?? false;
|
|
3206
3207
|
const hideOutput = this.traceState?.hideOutput ?? false;
|
|
3208
|
+
const nestedUnderParent = this.traceState?.nestedUnderParent ?? false;
|
|
3207
3209
|
return {
|
|
3208
3210
|
id: this.id,
|
|
3209
3211
|
traceId: this.traceId,
|
|
@@ -3225,7 +3227,8 @@ var BaseSpan = class BaseSpan {
|
|
|
3225
3227
|
...this.isInternal ? { isInternal: true } : {},
|
|
3226
3228
|
parentSpanId: this.getParentSpanId(includeInternalSpans),
|
|
3227
3229
|
externalParentSpanId: this.getExportedExternalParentSpanId(includeInternalSpans),
|
|
3228
|
-
...
|
|
3230
|
+
...nestedUnderParent ? { nestedUnderParent: true } : {},
|
|
3231
|
+
...this.isRootSpan && !nestedUnderParent && this.tags?.length ? { tags: this.tags } : {}
|
|
3229
3232
|
};
|
|
3230
3233
|
}
|
|
3231
3234
|
get externalTraceId() {
|
|
@@ -3238,7 +3241,7 @@ var BaseSpan = class BaseSpan {
|
|
|
3238
3241
|
async executeInContext(fn) {
|
|
3239
3242
|
const bridge = this.observabilityInstance.getBridge();
|
|
3240
3243
|
if (bridge?.executeInContext) {
|
|
3241
|
-
const bridgeContextSpan = this.isInternal ? this.getParentSpan(false) : this;
|
|
3244
|
+
const bridgeContextSpan = this.isInternal || this.isExcluded ? this.getParentSpan(false) : this;
|
|
3242
3245
|
return bridge.executeInContext(bridgeContextSpan?.id ?? this.id, fn);
|
|
3243
3246
|
}
|
|
3244
3247
|
return fn();
|
|
@@ -3250,7 +3253,7 @@ var BaseSpan = class BaseSpan {
|
|
|
3250
3253
|
executeInContextSync(fn) {
|
|
3251
3254
|
const bridge = this.observabilityInstance.getBridge();
|
|
3252
3255
|
if (bridge?.executeInContextSync) {
|
|
3253
|
-
const bridgeContextSpan = this.isInternal ? this.getParentSpan(false) : this;
|
|
3256
|
+
const bridgeContextSpan = this.isInternal || this.isExcluded ? this.getParentSpan(false) : this;
|
|
3254
3257
|
return bridge.executeInContextSync(bridgeContextSpan?.id ?? this.id, fn);
|
|
3255
3258
|
}
|
|
3256
3259
|
return fn();
|
|
@@ -3295,7 +3298,7 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
3295
3298
|
return;
|
|
3296
3299
|
}
|
|
3297
3300
|
const bridge = observabilityInstance.getBridge();
|
|
3298
|
-
if (bridge && !this.isInternal) {
|
|
3301
|
+
if (bridge && !this.isInternal && !this.isExcluded) {
|
|
3299
3302
|
const bridgeIds = bridge.createSpan(options);
|
|
3300
3303
|
if (bridgeIds) {
|
|
3301
3304
|
this.id = bridgeIds.spanId;
|
|
@@ -4772,6 +4775,11 @@ var BaseObservabilityInstance = class extends _mastra_core_base.MastraBase {
|
|
|
4772
4775
|
tags,
|
|
4773
4776
|
requestContext
|
|
4774
4777
|
});
|
|
4778
|
+
if (!options.parent && traceState?.nestedUnderParent && (!tracingOptions?.traceId || span.traceId !== tracingOptions.traceId || !tracingOptions.parentSpanId || !(span instanceof BaseSpan) || span.externalParentSpanId !== tracingOptions.parentSpanId)) {
|
|
4779
|
+
const { nestedUnderParent: _ignored, ...ownTraceState } = traceState;
|
|
4780
|
+
span.traceState = ownTraceState;
|
|
4781
|
+
this.logger.debug("[Observability] Ignoring tracingOptions.nestUnderParent: the run did not join the requested trace under the requested parent");
|
|
4782
|
+
}
|
|
4775
4783
|
if (rest.type === _mastra_core_observability.SpanType.MODEL_GENERATION && this.config.excludeSpanTypes?.includes(_mastra_core_observability.SpanType.MODEL_GENERATION)) {
|
|
4776
4784
|
const attrs = rest.attributes;
|
|
4777
4785
|
const model = resolveModelId(attrs?.responseModel, attrs?.model);
|
|
@@ -4807,6 +4815,7 @@ var BaseObservabilityInstance = class extends _mastra_core_base.MastraBase {
|
|
|
4807
4815
|
traceId: cached.traceId,
|
|
4808
4816
|
spanId: cached.id,
|
|
4809
4817
|
parentSpanId: cached.parentSpanId,
|
|
4818
|
+
externalParentSpanId: cached.externalParentSpanId,
|
|
4810
4819
|
startTime: cached.startTime instanceof Date ? cached.startTime : new Date(cached.startTime),
|
|
4811
4820
|
input: cached.input,
|
|
4812
4821
|
attributes: cached.attributes,
|
|
@@ -4814,7 +4823,11 @@ var BaseObservabilityInstance = class extends _mastra_core_base.MastraBase {
|
|
|
4814
4823
|
entityType: cached.entityType,
|
|
4815
4824
|
entityId: cached.entityId,
|
|
4816
4825
|
entityName: cached.entityName,
|
|
4817
|
-
tracingPolicy: cached.isInternal ? { internal: _mastra_core_observability.InternalSpans.ALL } : void 0
|
|
4826
|
+
tracingPolicy: cached.isInternal ? { internal: _mastra_core_observability.InternalSpans.ALL } : void 0,
|
|
4827
|
+
traceState: cached.nestedUnderParent ? {
|
|
4828
|
+
requestContextKeys: [],
|
|
4829
|
+
nestedUnderParent: true
|
|
4830
|
+
} : void 0
|
|
4818
4831
|
});
|
|
4819
4832
|
this.wireSpanLifecycle(span);
|
|
4820
4833
|
return span;
|
|
@@ -5018,11 +5031,13 @@ var BaseObservabilityInstance = class extends _mastra_core_base.MastraBase {
|
|
|
5018
5031
|
const allKeys = [...configuredKeys, ...additionalKeys];
|
|
5019
5032
|
const hideInput = tracingOptions?.hideInput;
|
|
5020
5033
|
const hideOutput = tracingOptions?.hideOutput;
|
|
5021
|
-
|
|
5034
|
+
const nestedUnderParent = tracingOptions?.nestUnderParent === true;
|
|
5035
|
+
if (allKeys.length === 0 && !hideInput && !hideOutput && !nestedUnderParent) return;
|
|
5022
5036
|
return {
|
|
5023
5037
|
requestContextKeys: allKeys,
|
|
5024
5038
|
...hideInput !== void 0 && { hideInput },
|
|
5025
|
-
...hideOutput !== void 0 && { hideOutput }
|
|
5039
|
+
...hideOutput !== void 0 && { hideOutput },
|
|
5040
|
+
...nestedUnderParent && { nestedUnderParent }
|
|
5026
5041
|
};
|
|
5027
5042
|
}
|
|
5028
5043
|
/**
|
|
@@ -5894,6 +5909,12 @@ var TraceData = class {
|
|
|
5894
5909
|
this.#waitingForParent.delete(args.spanId);
|
|
5895
5910
|
}
|
|
5896
5911
|
/**
|
|
5912
|
+
* Get the span IDs that have events waiting on them.
|
|
5913
|
+
*/
|
|
5914
|
+
getWaitingForSpanIds() {
|
|
5915
|
+
return [...this.#waitingForParent.keys()];
|
|
5916
|
+
}
|
|
5917
|
+
/**
|
|
5897
5918
|
* Get total count of events in all waiting queues.
|
|
5898
5919
|
*/
|
|
5899
5920
|
waitingQueueSize() {
|
|
@@ -6077,6 +6098,8 @@ var TrackingExporter = class extends BaseExporter {
|
|
|
6077
6098
|
#hardCapEnforcementInProgress = false;
|
|
6078
6099
|
/** Map of traceId to scheduled cleanup timeout */
|
|
6079
6100
|
#pendingCleanups = /* @__PURE__ */ new Map();
|
|
6101
|
+
/** Waiting-queue replays started by setImmediate that haven't finished yet */
|
|
6102
|
+
#activeReplays = /* @__PURE__ */ new Set();
|
|
6080
6103
|
/** Subclass configuration with resolved values */
|
|
6081
6104
|
config;
|
|
6082
6105
|
/** Maximum attempts to process a queued event before dropping */
|
|
@@ -6104,12 +6127,13 @@ var TrackingExporter = class extends BaseExporter {
|
|
|
6104
6127
|
*/
|
|
6105
6128
|
#scheduleProcessWaitingForRoot(traceId) {
|
|
6106
6129
|
setImmediate(() => {
|
|
6107
|
-
this.#
|
|
6130
|
+
if (this.#shutdownStarted) return;
|
|
6131
|
+
this.#trackReplay(this.#processWaitingForRoot(traceId).then(() => {}, (error) => {
|
|
6108
6132
|
this.logger.error(`${this.name}: Error processing waiting-for-root queue`, {
|
|
6109
6133
|
error,
|
|
6110
6134
|
traceId
|
|
6111
6135
|
});
|
|
6112
|
-
});
|
|
6136
|
+
}));
|
|
6113
6137
|
});
|
|
6114
6138
|
}
|
|
6115
6139
|
/**
|
|
@@ -6118,24 +6142,59 @@ var TrackingExporter = class extends BaseExporter {
|
|
|
6118
6142
|
*/
|
|
6119
6143
|
#scheduleProcessWaitingFor(traceId, spanId) {
|
|
6120
6144
|
setImmediate(() => {
|
|
6121
|
-
this.#
|
|
6145
|
+
if (this.#shutdownStarted) return;
|
|
6146
|
+
this.#trackReplay(this.#processWaitingFor(traceId, spanId).then(() => {}, (error) => {
|
|
6122
6147
|
this.logger.error(`${this.name}: Error processing waiting queue`, {
|
|
6123
6148
|
error,
|
|
6124
6149
|
traceId,
|
|
6125
6150
|
spanId
|
|
6126
6151
|
});
|
|
6127
|
-
});
|
|
6152
|
+
}));
|
|
6128
6153
|
});
|
|
6129
6154
|
}
|
|
6130
6155
|
/**
|
|
6156
|
+
* Track a running replay so flush() and shutdown() can wait for it.
|
|
6157
|
+
*/
|
|
6158
|
+
#trackReplay(replay) {
|
|
6159
|
+
this.#activeReplays.add(replay);
|
|
6160
|
+
replay.finally(() => this.#activeReplays.delete(replay));
|
|
6161
|
+
}
|
|
6162
|
+
/**
|
|
6163
|
+
* Process every queued event whose dependency has been built, without waiting for the
|
|
6164
|
+
* setImmediate-scheduled replays (which never fire under fake timers). Waits for replays
|
|
6165
|
+
* that are already running, then repeats until a pass makes no progress, so cascades
|
|
6166
|
+
* (root -> parent -> child -> end) are fully drained.
|
|
6167
|
+
*/
|
|
6168
|
+
async #drainWaitingQueues() {
|
|
6169
|
+
while (true) {
|
|
6170
|
+
while (this.#activeReplays.size > 0) await Promise.all(this.#activeReplays);
|
|
6171
|
+
let progressed = false;
|
|
6172
|
+
for (const [traceId, traceData] of this.#traceMap) try {
|
|
6173
|
+
if (traceData.isRootProcessed() && await this.#processWaitingForRoot(traceId) > 0) progressed = true;
|
|
6174
|
+
for (const spanId of traceData.getWaitingForSpanIds()) {
|
|
6175
|
+
if (!traceData.hasSpan({ spanId })) continue;
|
|
6176
|
+
if (await this.#processWaitingFor(traceId, spanId) > 0) progressed = true;
|
|
6177
|
+
}
|
|
6178
|
+
} catch (error) {
|
|
6179
|
+
this.logger.error(`${this.name}: Error draining waiting queues`, {
|
|
6180
|
+
error,
|
|
6181
|
+
traceId
|
|
6182
|
+
});
|
|
6183
|
+
}
|
|
6184
|
+
if (!progressed && this.#activeReplays.size === 0) return;
|
|
6185
|
+
}
|
|
6186
|
+
}
|
|
6187
|
+
/**
|
|
6131
6188
|
* Process all events waiting for root span.
|
|
6189
|
+
* Takes the queue before processing, so a concurrent call can't process the same events.
|
|
6190
|
+
* @returns The number of events that left the queue (processed, moved or dropped)
|
|
6132
6191
|
*/
|
|
6133
6192
|
async #processWaitingForRoot(traceId) {
|
|
6134
|
-
if (this.#shutdownStarted) return;
|
|
6135
6193
|
const traceData = this.#traceMap.get(traceId);
|
|
6136
|
-
if (!traceData) return;
|
|
6194
|
+
if (!traceData) return 0;
|
|
6137
6195
|
const queue = traceData.getEventsWaitingForRoot();
|
|
6138
|
-
if (queue.length === 0) return;
|
|
6196
|
+
if (queue.length === 0) return 0;
|
|
6197
|
+
traceData.clearWaitingForRoot();
|
|
6139
6198
|
this.logger.debug(`${this.name}: Processing ${queue.length} events waiting for root`, { traceId });
|
|
6140
6199
|
const toKeep = [];
|
|
6141
6200
|
const now = Date.now();
|
|
@@ -6171,23 +6230,25 @@ var TrackingExporter = class extends BaseExporter {
|
|
|
6171
6230
|
else toKeep.push(queuedEvent);
|
|
6172
6231
|
}
|
|
6173
6232
|
}
|
|
6174
|
-
traceData.clearWaitingForRoot();
|
|
6175
6233
|
for (const event of toKeep) traceData.addToWaitingQueue({
|
|
6176
6234
|
event: event.event,
|
|
6177
6235
|
waitingFor: "root",
|
|
6178
6236
|
attempts: event.attempts,
|
|
6179
6237
|
queuedAt: event.queuedAt
|
|
6180
6238
|
});
|
|
6239
|
+
return queue.length - toKeep.length;
|
|
6181
6240
|
}
|
|
6182
6241
|
/**
|
|
6183
6242
|
* Process events waiting for a specific parent span.
|
|
6243
|
+
* Takes the queue before processing, so a concurrent call can't process the same events.
|
|
6244
|
+
* @returns The number of events that left the queue (processed, moved or dropped)
|
|
6184
6245
|
*/
|
|
6185
6246
|
async #processWaitingFor(traceId, spanId) {
|
|
6186
|
-
if (this.#shutdownStarted) return;
|
|
6187
6247
|
const traceData = this.#traceMap.get(traceId);
|
|
6188
|
-
if (!traceData) return;
|
|
6248
|
+
if (!traceData) return 0;
|
|
6189
6249
|
const queue = traceData.getEventsWaitingFor({ spanId });
|
|
6190
|
-
if (queue.length === 0) return;
|
|
6250
|
+
if (queue.length === 0) return 0;
|
|
6251
|
+
traceData.clearWaitingFor({ spanId });
|
|
6191
6252
|
this.logger.debug(`${this.name}: Processing ${queue.length} events waiting for span`, {
|
|
6192
6253
|
traceId,
|
|
6193
6254
|
spanId
|
|
@@ -6217,13 +6278,13 @@ var TrackingExporter = class extends BaseExporter {
|
|
|
6217
6278
|
queuedEvent.attempts++;
|
|
6218
6279
|
if (!await this.#tryProcessQueuedEvent(queuedEvent, traceData)) toKeep.push(queuedEvent);
|
|
6219
6280
|
}
|
|
6220
|
-
traceData.clearWaitingFor({ spanId });
|
|
6221
6281
|
for (const event of toKeep) traceData.addToWaitingQueue({
|
|
6222
6282
|
event: event.event,
|
|
6223
6283
|
waitingFor: spanId,
|
|
6224
6284
|
attempts: event.attempts,
|
|
6225
6285
|
queuedAt: event.queuedAt
|
|
6226
6286
|
});
|
|
6287
|
+
return queue.length - toKeep.length;
|
|
6227
6288
|
}
|
|
6228
6289
|
/**
|
|
6229
6290
|
* Try to process a queued event.
|
|
@@ -6683,11 +6744,15 @@ var TrackingExporter = class extends BaseExporter {
|
|
|
6683
6744
|
* This is useful in serverless environments where you need to ensure spans
|
|
6684
6745
|
* are exported before the runtime instance is terminated.
|
|
6685
6746
|
*
|
|
6747
|
+
* Queued events whose dependencies have been built are processed first, so
|
|
6748
|
+
* a shutdown() right after flush() only aborts spans that are still open.
|
|
6749
|
+
*
|
|
6686
6750
|
* Subclasses should override _flush() to implement vendor-specific flush logic.
|
|
6687
6751
|
*/
|
|
6688
6752
|
async flush() {
|
|
6689
6753
|
if (this.isDisabled) return;
|
|
6690
6754
|
this.logger.debug(`${this.name}: Flushing`);
|
|
6755
|
+
if (!this.#shutdownStarted) await this.#drainWaitingQueues();
|
|
6691
6756
|
await this._flush();
|
|
6692
6757
|
}
|
|
6693
6758
|
/**
|
|
@@ -6707,6 +6772,7 @@ var TrackingExporter = class extends BaseExporter {
|
|
|
6707
6772
|
async shutdown() {
|
|
6708
6773
|
if (this.isDisabled) return;
|
|
6709
6774
|
this.#shutdownStarted = true;
|
|
6775
|
+
await this.#drainWaitingQueues();
|
|
6710
6776
|
await this._preShutdown();
|
|
6711
6777
|
for (const [traceId, timeout] of this.#pendingCleanups) {
|
|
6712
6778
|
clearTimeout(timeout);
|