@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @mastra/observability
|
|
2
2
|
|
|
3
|
+
## 1.17.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Fixed traces that start under an external parent span not appearing in Mastra Studio. ([#20499](https://github.com/mastra-ai/mastra/pull/20499))
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`088e41e`](https://github.com/mastra-ai/mastra/commit/088e41e434ed05f2c674b254f1034ec46a57a7be), [`b2f0013`](https://github.com/mastra-ai/mastra/commit/b2f0013375588d40c03c13e843b99c0ff8872ca5), [`3b541ae`](https://github.com/mastra-ai/mastra/commit/3b541ae5d410c52b80a7e381d84d021cddb9a449), [`ae79e34`](https://github.com/mastra-ai/mastra/commit/ae79e34c0bd8674fc24c7524217bfc4a051c6136), [`a6c4399`](https://github.com/mastra-ai/mastra/commit/a6c4399763590b3dae21a2c81826e89a3b1deee4)]:
|
|
12
|
+
- @mastra/core@1.59.0-alpha.0
|
|
13
|
+
|
|
3
14
|
## 1.16.6
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -2541,8 +2541,10 @@ var BaseSpan = class {
|
|
|
2541
2541
|
entityId;
|
|
2542
2542
|
/** Entity name that created the span */
|
|
2543
2543
|
entityName;
|
|
2544
|
-
/** Parent span
|
|
2544
|
+
/** 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) */
|
|
2545
2545
|
parentSpanId;
|
|
2546
|
+
/** 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 */
|
|
2547
|
+
externalParentSpanId;
|
|
2546
2548
|
/** Deep clean options for serialization */
|
|
2547
2549
|
deepCleanOptions;
|
|
2548
2550
|
/**
|
|
@@ -2649,6 +2651,17 @@ var BaseSpan = class {
|
|
|
2649
2651
|
if (parentSpan) return parentSpan.id;
|
|
2650
2652
|
return this.parent.getParentSpanId(includeInternalSpans);
|
|
2651
2653
|
}
|
|
2654
|
+
/**
|
|
2655
|
+
* External (foreign tracing-system) parent id to export alongside
|
|
2656
|
+
* {@link getParentSpanId}. When every Mastra ancestor is dropped from
|
|
2657
|
+
* export, the span is exported at the root's position, so the root's
|
|
2658
|
+
* external parent must travel with it.
|
|
2659
|
+
*/
|
|
2660
|
+
getExportedExternalParentSpanId(includeInternalSpans) {
|
|
2661
|
+
if (!this.parent) return this.externalParentSpanId;
|
|
2662
|
+
if (this.getParentSpan(includeInternalSpans)) return this.externalParentSpanId;
|
|
2663
|
+
return this.parent.getExportedExternalParentSpanId(includeInternalSpans);
|
|
2664
|
+
}
|
|
2652
2665
|
/** Find the closest parent span of a specific type by walking up the parent chain */
|
|
2653
2666
|
findParent(spanType) {
|
|
2654
2667
|
let current = this.parent;
|
|
@@ -2723,6 +2736,7 @@ var BaseSpan = class {
|
|
|
2723
2736
|
isEvent: this.isEvent,
|
|
2724
2737
|
isRootSpan: this.isRootSpan,
|
|
2725
2738
|
parentSpanId: this.getParentSpanId(includeInternalSpans),
|
|
2739
|
+
externalParentSpanId: this.getExportedExternalParentSpanId(includeInternalSpans),
|
|
2726
2740
|
...this.isRootSpan && this.tags?.length ? { tags: this.tags } : {}
|
|
2727
2741
|
};
|
|
2728
2742
|
}
|
|
@@ -2765,6 +2779,7 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
2765
2779
|
this.id = options.spanId;
|
|
2766
2780
|
this.traceId = options.traceId;
|
|
2767
2781
|
if (options.parentSpanId) this.parentSpanId = options.parentSpanId;
|
|
2782
|
+
if (options.externalParentSpanId) this.externalParentSpanId = options.externalParentSpanId;
|
|
2768
2783
|
return;
|
|
2769
2784
|
}
|
|
2770
2785
|
const bridge = observabilityInstance.getBridge();
|
|
@@ -2773,7 +2788,8 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
2773
2788
|
if (bridgeIds) {
|
|
2774
2789
|
this.id = bridgeIds.spanId;
|
|
2775
2790
|
this.traceId = bridgeIds.traceId;
|
|
2776
|
-
this.parentSpanId = bridgeIds.parentSpanId;
|
|
2791
|
+
this.parentSpanId = options.parentSpanId ?? bridgeIds.parentSpanId;
|
|
2792
|
+
this.externalParentSpanId = options.externalParentSpanId ?? bridgeIds.externalParentSpanId;
|
|
2777
2793
|
return;
|
|
2778
2794
|
}
|
|
2779
2795
|
}
|
|
@@ -2787,6 +2803,8 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
2787
2803
|
this.id = generateSpanId();
|
|
2788
2804
|
if (options.parentSpanId) if (isValidSpanId(options.parentSpanId)) this.parentSpanId = options.parentSpanId;
|
|
2789
2805
|
else console.error(`[Mastra Tracing] Invalid parentSpanId: must be 1-16 hexadecimal characters, got "${options.parentSpanId}". Ignoring.`);
|
|
2806
|
+
if (options.externalParentSpanId) if (isValidSpanId(options.externalParentSpanId)) this.externalParentSpanId = options.externalParentSpanId;
|
|
2807
|
+
else console.error(`[Mastra Tracing] Invalid externalParentSpanId: must be 1-16 hexadecimal characters, got "${options.externalParentSpanId}". Ignoring.`);
|
|
2790
2808
|
}
|
|
2791
2809
|
end(options) {
|
|
2792
2810
|
if (this.isEvent) return;
|
|
@@ -3035,11 +3053,13 @@ var BaseObservabilityInstance = class extends _mastra_core_base.MastraBase {
|
|
|
3035
3053
|
} : enrichedMetadata;
|
|
3036
3054
|
const tags = !options.parent ? tracingOptions?.tags : void 0;
|
|
3037
3055
|
const traceId = !options.parent ? options.traceId ?? tracingOptions?.traceId : options.traceId;
|
|
3038
|
-
const parentSpanId =
|
|
3056
|
+
const parentSpanId = options.parentSpanId;
|
|
3057
|
+
const externalParentSpanId = !options.parent ? options.externalParentSpanId ?? tracingOptions?.parentSpanId : options.externalParentSpanId;
|
|
3039
3058
|
const span = this.createSpan({
|
|
3040
3059
|
...rest,
|
|
3041
3060
|
traceId,
|
|
3042
3061
|
parentSpanId,
|
|
3062
|
+
externalParentSpanId,
|
|
3043
3063
|
metadata: finalMetadata,
|
|
3044
3064
|
traceState,
|
|
3045
3065
|
tags,
|