@mastra/observability 1.16.6 → 1.17.0-alpha.0
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 +11 -0
- package/dist/index.cjs +23 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -3
- package/dist/index.js.map +1 -1
- package/dist/instances/base.d.ts.map +1 -1
- package/dist/spans/base.d.ts +10 -1
- package/dist/spans/base.d.ts.map +1 -1
- package/dist/spans/default.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2516,8 +2516,10 @@ var BaseSpan = class {
|
|
|
2516
2516
|
entityId;
|
|
2517
2517
|
/** Entity name that created the span */
|
|
2518
2518
|
entityName;
|
|
2519
|
-
/** Parent span
|
|
2519
|
+
/** Parent span within this Mastra trace: a span Mastra created (the span-tree parent, or a prior Mastra span such as the suspended run a resume links back to) */
|
|
2520
2520
|
parentSpanId;
|
|
2521
|
+
/** Parent from an external tracing system (ambient OTel / dd-trace span) that Mastra did not create; carried for external correlation, not part of Mastra's own parent/child linkage */
|
|
2522
|
+
externalParentSpanId;
|
|
2521
2523
|
/** Deep clean options for serialization */
|
|
2522
2524
|
deepCleanOptions;
|
|
2523
2525
|
/**
|
|
@@ -2624,6 +2626,17 @@ var BaseSpan = class {
|
|
|
2624
2626
|
if (parentSpan) return parentSpan.id;
|
|
2625
2627
|
return this.parent.getParentSpanId(includeInternalSpans);
|
|
2626
2628
|
}
|
|
2629
|
+
/**
|
|
2630
|
+
* External (foreign tracing-system) parent id to export alongside
|
|
2631
|
+
* {@link getParentSpanId}. When every Mastra ancestor is dropped from
|
|
2632
|
+
* export, the span is exported at the root's position, so the root's
|
|
2633
|
+
* external parent must travel with it.
|
|
2634
|
+
*/
|
|
2635
|
+
getExportedExternalParentSpanId(includeInternalSpans) {
|
|
2636
|
+
if (!this.parent) return this.externalParentSpanId;
|
|
2637
|
+
if (this.getParentSpan(includeInternalSpans)) return this.externalParentSpanId;
|
|
2638
|
+
return this.parent.getExportedExternalParentSpanId(includeInternalSpans);
|
|
2639
|
+
}
|
|
2627
2640
|
/** Find the closest parent span of a specific type by walking up the parent chain */
|
|
2628
2641
|
findParent(spanType) {
|
|
2629
2642
|
let current = this.parent;
|
|
@@ -2698,6 +2711,7 @@ var BaseSpan = class {
|
|
|
2698
2711
|
isEvent: this.isEvent,
|
|
2699
2712
|
isRootSpan: this.isRootSpan,
|
|
2700
2713
|
parentSpanId: this.getParentSpanId(includeInternalSpans),
|
|
2714
|
+
externalParentSpanId: this.getExportedExternalParentSpanId(includeInternalSpans),
|
|
2701
2715
|
...this.isRootSpan && this.tags?.length ? { tags: this.tags } : {}
|
|
2702
2716
|
};
|
|
2703
2717
|
}
|
|
@@ -2740,6 +2754,7 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
2740
2754
|
this.id = options.spanId;
|
|
2741
2755
|
this.traceId = options.traceId;
|
|
2742
2756
|
if (options.parentSpanId) this.parentSpanId = options.parentSpanId;
|
|
2757
|
+
if (options.externalParentSpanId) this.externalParentSpanId = options.externalParentSpanId;
|
|
2743
2758
|
return;
|
|
2744
2759
|
}
|
|
2745
2760
|
const bridge = observabilityInstance.getBridge();
|
|
@@ -2748,7 +2763,8 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
2748
2763
|
if (bridgeIds) {
|
|
2749
2764
|
this.id = bridgeIds.spanId;
|
|
2750
2765
|
this.traceId = bridgeIds.traceId;
|
|
2751
|
-
this.parentSpanId = bridgeIds.parentSpanId;
|
|
2766
|
+
this.parentSpanId = options.parentSpanId ?? bridgeIds.parentSpanId;
|
|
2767
|
+
this.externalParentSpanId = options.externalParentSpanId ?? bridgeIds.externalParentSpanId;
|
|
2752
2768
|
return;
|
|
2753
2769
|
}
|
|
2754
2770
|
}
|
|
@@ -2762,6 +2778,8 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
2762
2778
|
this.id = generateSpanId();
|
|
2763
2779
|
if (options.parentSpanId) if (isValidSpanId(options.parentSpanId)) this.parentSpanId = options.parentSpanId;
|
|
2764
2780
|
else console.error(`[Mastra Tracing] Invalid parentSpanId: must be 1-16 hexadecimal characters, got "${options.parentSpanId}". Ignoring.`);
|
|
2781
|
+
if (options.externalParentSpanId) if (isValidSpanId(options.externalParentSpanId)) this.externalParentSpanId = options.externalParentSpanId;
|
|
2782
|
+
else console.error(`[Mastra Tracing] Invalid externalParentSpanId: must be 1-16 hexadecimal characters, got "${options.externalParentSpanId}". Ignoring.`);
|
|
2765
2783
|
}
|
|
2766
2784
|
end(options) {
|
|
2767
2785
|
if (this.isEvent) return;
|
|
@@ -3010,11 +3028,13 @@ var BaseObservabilityInstance = class extends MastraBase {
|
|
|
3010
3028
|
} : enrichedMetadata;
|
|
3011
3029
|
const tags = !options.parent ? tracingOptions?.tags : void 0;
|
|
3012
3030
|
const traceId = !options.parent ? options.traceId ?? tracingOptions?.traceId : options.traceId;
|
|
3013
|
-
const parentSpanId =
|
|
3031
|
+
const parentSpanId = options.parentSpanId;
|
|
3032
|
+
const externalParentSpanId = !options.parent ? options.externalParentSpanId ?? tracingOptions?.parentSpanId : options.externalParentSpanId;
|
|
3014
3033
|
const span = this.createSpan({
|
|
3015
3034
|
...rest,
|
|
3016
3035
|
traceId,
|
|
3017
3036
|
parentSpanId,
|
|
3037
|
+
externalParentSpanId,
|
|
3018
3038
|
metadata: finalMetadata,
|
|
3019
3039
|
traceState,
|
|
3020
3040
|
tags,
|