@mastra/observability 1.17.2-alpha.1 → 1.17.2
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/CHANGELOG.md +40 -0
- package/dist/index.cjs +18 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/instances/base.d.ts.map +1 -1
- package/dist/spans/base.d.ts +5 -0
- package/dist/spans/base.d.ts.map +1 -1
- package/dist/spans/default.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -2693,7 +2693,7 @@ function getExternalParentId(options) {
|
|
|
2693
2693
|
if (parent.isInternal || parent.isExcluded) return parent.getParentSpanId(false);
|
|
2694
2694
|
return parent.id;
|
|
2695
2695
|
}
|
|
2696
|
-
var BaseSpan = class {
|
|
2696
|
+
var BaseSpan = class BaseSpan {
|
|
2697
2697
|
name;
|
|
2698
2698
|
type;
|
|
2699
2699
|
attributes;
|
|
@@ -2743,6 +2743,8 @@ var BaseSpan = class {
|
|
|
2743
2743
|
isExcluded;
|
|
2744
2744
|
/** Cached canonical correlation context for this live span */
|
|
2745
2745
|
correlationContext;
|
|
2746
|
+
/** Child spans that have started but not yet ended */
|
|
2747
|
+
#openChildren;
|
|
2746
2748
|
/**
|
|
2747
2749
|
* Subclasses can override to unconditionally mark the span as excluded.
|
|
2748
2750
|
* NoOpSpan uses this because it is never exported regardless of config.
|
|
@@ -2764,6 +2766,8 @@ var BaseSpan = class {
|
|
|
2764
2766
|
this.isEvent = options.isEvent ?? false;
|
|
2765
2767
|
this.tracingPolicy = options.tracingPolicy;
|
|
2766
2768
|
this.traceState = options.traceState;
|
|
2769
|
+
const parent = options.parent;
|
|
2770
|
+
if (!this.isEvent && parent instanceof BaseSpan && parent.isValid) (parent.#openChildren ??= /* @__PURE__ */ new Set()).add(this);
|
|
2767
2771
|
this.tags = !options.parent && options.tags?.length ? options.tags : void 0;
|
|
2768
2772
|
const entityParent = this.getParentSpan(false);
|
|
2769
2773
|
this.entityType = options.entityType ?? entityParent?.entityType;
|
|
@@ -2801,6 +2805,16 @@ var BaseSpan = class {
|
|
|
2801
2805
|
return value;
|
|
2802
2806
|
}
|
|
2803
2807
|
}
|
|
2808
|
+
/** End the span and any descendant spans that are still open, applying `options` to each */
|
|
2809
|
+
endTree(options) {
|
|
2810
|
+
if (this.#openChildren) for (const child of [...this.#openChildren]) child.endTree(options);
|
|
2811
|
+
this.end(options);
|
|
2812
|
+
}
|
|
2813
|
+
/** Release this span from its parent's open-child set once it has ended */
|
|
2814
|
+
detachFromParent() {
|
|
2815
|
+
const parent = this.parent;
|
|
2816
|
+
if (parent instanceof BaseSpan) parent.#openChildren?.delete(this);
|
|
2817
|
+
}
|
|
2804
2818
|
createChildSpan(options) {
|
|
2805
2819
|
return this.observabilityInstance.startSpan({
|
|
2806
2820
|
...options,
|
|
@@ -3004,7 +3018,9 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
3004
3018
|
}
|
|
3005
3019
|
end(options) {
|
|
3006
3020
|
if (this.isEvent) return;
|
|
3021
|
+
if (this.endTime) return;
|
|
3007
3022
|
this.endTime = /* @__PURE__ */ new Date();
|
|
3023
|
+
this.detachFromParent();
|
|
3008
3024
|
if (options?.metadata) this.metadata = {
|
|
3009
3025
|
...this.metadata,
|
|
3010
3026
|
...deepClean(this.prepareSpanMetadata(options.metadata), this.deepCleanOptions)
|
|
@@ -3460,6 +3476,7 @@ var BaseObservabilityInstance = class extends MastraBase {
|
|
|
3460
3476
|
this.logger.warn(`End event is not available on event spans`);
|
|
3461
3477
|
return;
|
|
3462
3478
|
}
|
|
3479
|
+
if (span.endTime) return;
|
|
3463
3480
|
const rollupTarget = this.captureModelUsageRollup(span, options);
|
|
3464
3481
|
const excludedModelUsage = this.captureExcludedModelUsage(span, options);
|
|
3465
3482
|
originalEnd(options);
|