@mastra/observability 1.11.0 → 1.11.1-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 +37 -0
- package/dist/index.cjs +20 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -5
- package/dist/index.js.map +1 -1
- package/dist/model-tracing.d.ts.map +1 -1
- package/dist/spans/base.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -18733,7 +18733,11 @@ function summarizeRequestBody(body) {
|
|
|
18733
18733
|
}
|
|
18734
18734
|
return Object.keys(summary).length > 0 ? summary : "[request body]";
|
|
18735
18735
|
}
|
|
18736
|
-
function extractStepInput(
|
|
18736
|
+
function extractStepInput(payload) {
|
|
18737
|
+
if (Array.isArray(payload?.inputMessages)) {
|
|
18738
|
+
return normalizeMessages(payload.inputMessages);
|
|
18739
|
+
}
|
|
18740
|
+
const request = payload?.request;
|
|
18737
18741
|
if (!request) return void 0;
|
|
18738
18742
|
const { body } = request;
|
|
18739
18743
|
if (body == null) return request;
|
|
@@ -18753,6 +18757,7 @@ var ModelSpanTracker = class {
|
|
|
18753
18757
|
#stepIndex = 0;
|
|
18754
18758
|
#chunkSequence = 0;
|
|
18755
18759
|
#completionStartTime;
|
|
18760
|
+
#currentStepInputIsFinal = false;
|
|
18756
18761
|
/** When true, step-finish chunks don't auto-close the step span (for durable execution) */
|
|
18757
18762
|
#deferStepClose = false;
|
|
18758
18763
|
/** Stored step-finish payload when defer mode is enabled */
|
|
@@ -18846,6 +18851,7 @@ var ModelSpanTracker = class {
|
|
|
18846
18851
|
if (this.#currentStepSpan) {
|
|
18847
18852
|
return;
|
|
18848
18853
|
}
|
|
18854
|
+
const input = extractStepInput(payload);
|
|
18849
18855
|
this.#currentStepSpan = this.#modelSpan?.createChildSpan({
|
|
18850
18856
|
name: `step: ${this.#stepIndex}`,
|
|
18851
18857
|
type: SpanType.MODEL_STEP,
|
|
@@ -18854,8 +18860,9 @@ var ModelSpanTracker = class {
|
|
|
18854
18860
|
...payload?.messageId ? { messageId: payload.messageId } : {},
|
|
18855
18861
|
...payload?.warnings?.length ? { warnings: payload.warnings } : {}
|
|
18856
18862
|
},
|
|
18857
|
-
input
|
|
18863
|
+
input
|
|
18858
18864
|
});
|
|
18865
|
+
this.#currentStepInputIsFinal = Array.isArray(payload?.inputMessages);
|
|
18859
18866
|
this.#chunkSequence = 0;
|
|
18860
18867
|
}
|
|
18861
18868
|
/**
|
|
@@ -18866,13 +18873,18 @@ var ModelSpanTracker = class {
|
|
|
18866
18873
|
if (!this.#currentStepSpan || !payload) {
|
|
18867
18874
|
return;
|
|
18868
18875
|
}
|
|
18876
|
+
const hasFinalInput = Array.isArray(payload.inputMessages);
|
|
18877
|
+
const input = hasFinalInput || !this.#currentStepInputIsFinal ? extractStepInput(payload) : void 0;
|
|
18869
18878
|
this.#currentStepSpan.update({
|
|
18870
|
-
input:
|
|
18879
|
+
...input !== void 0 ? { input } : {},
|
|
18871
18880
|
attributes: {
|
|
18872
18881
|
...payload.messageId ? { messageId: payload.messageId } : {},
|
|
18873
18882
|
...payload.warnings?.length ? { warnings: payload.warnings } : {}
|
|
18874
18883
|
}
|
|
18875
18884
|
});
|
|
18885
|
+
if (hasFinalInput) {
|
|
18886
|
+
this.#currentStepInputIsFinal = true;
|
|
18887
|
+
}
|
|
18876
18888
|
}
|
|
18877
18889
|
/**
|
|
18878
18890
|
* End the current Model execution step with token usage, finish reason, output, and metadata
|
|
@@ -18904,6 +18916,7 @@ var ModelSpanTracker = class {
|
|
|
18904
18916
|
}
|
|
18905
18917
|
});
|
|
18906
18918
|
this.#currentStepSpan = void 0;
|
|
18919
|
+
this.#currentStepInputIsFinal = false;
|
|
18907
18920
|
this.#stepIndex++;
|
|
18908
18921
|
}
|
|
18909
18922
|
/**
|
|
@@ -19479,7 +19492,8 @@ var BaseSpan = class {
|
|
|
19479
19492
|
async executeInContext(fn) {
|
|
19480
19493
|
const bridge = this.observabilityInstance.getBridge();
|
|
19481
19494
|
if (bridge?.executeInContext) {
|
|
19482
|
-
|
|
19495
|
+
const bridgeContextSpan = this.isInternal ? this.getParentSpan(false) : this;
|
|
19496
|
+
return bridge.executeInContext(bridgeContextSpan?.id ?? this.id, fn);
|
|
19483
19497
|
}
|
|
19484
19498
|
return fn();
|
|
19485
19499
|
}
|
|
@@ -19490,7 +19504,8 @@ var BaseSpan = class {
|
|
|
19490
19504
|
executeInContextSync(fn) {
|
|
19491
19505
|
const bridge = this.observabilityInstance.getBridge();
|
|
19492
19506
|
if (bridge?.executeInContextSync) {
|
|
19493
|
-
|
|
19507
|
+
const bridgeContextSpan = this.isInternal ? this.getParentSpan(false) : this;
|
|
19508
|
+
return bridge.executeInContextSync(bridgeContextSpan?.id ?? this.id, fn);
|
|
19494
19509
|
}
|
|
19495
19510
|
return fn();
|
|
19496
19511
|
}
|