@mastra/observability 1.10.2-alpha.0 → 1.10.3-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 +119 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/exporters/cloud.d.ts.map +1 -1
- package/dist/index.cjs +51 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +51 -2
- package/dist/index.js.map +1 -1
- package/dist/model-tracing.d.ts +26 -1
- package/dist/model-tracing.d.ts.map +1 -1
- package/dist/spans/base.d.ts +2 -1
- package/dist/spans/base.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -15043,6 +15043,7 @@ var SIGNAL_PUBLISH_SUFFIXES = {
|
|
|
15043
15043
|
scores: "/scores/publish",
|
|
15044
15044
|
feedback: "/feedback/publish"
|
|
15045
15045
|
};
|
|
15046
|
+
var DEFAULT_CLOUD_SPAN_FILTER = (span) => span.type !== SpanType.MODEL_CHUNK;
|
|
15046
15047
|
var SIGNAL_PUBLISH_SEGMENTS = {
|
|
15047
15048
|
traces: "spans",
|
|
15048
15049
|
logs: "logs",
|
|
@@ -15216,6 +15217,9 @@ var CloudExporter = class extends BaseExporter {
|
|
|
15216
15217
|
if (event.type !== TracingEventType.SPAN_ENDED) {
|
|
15217
15218
|
return;
|
|
15218
15219
|
}
|
|
15220
|
+
if (!DEFAULT_CLOUD_SPAN_FILTER(event.exportedSpan)) {
|
|
15221
|
+
return;
|
|
15222
|
+
}
|
|
15219
15223
|
this.addToBuffer(event);
|
|
15220
15224
|
await this.handleBufferedEvent();
|
|
15221
15225
|
}
|
|
@@ -17841,7 +17845,7 @@ var LoggerContextImpl = class {
|
|
|
17841
17845
|
* Build an ExportedLog, check against the minimum level, and emit it through the bus.
|
|
17842
17846
|
*/
|
|
17843
17847
|
log(level, message, data) {
|
|
17844
|
-
const minLevel = this.config.minLevel ?? "
|
|
17848
|
+
const minLevel = this.config.minLevel ?? "warn";
|
|
17845
17849
|
if (LOG_LEVEL_PRIORITY[level] < LOG_LEVEL_PRIORITY[minLevel]) {
|
|
17846
17850
|
return;
|
|
17847
17851
|
}
|
|
@@ -18749,6 +18753,10 @@ var ModelSpanTracker = class {
|
|
|
18749
18753
|
#stepIndex = 0;
|
|
18750
18754
|
#chunkSequence = 0;
|
|
18751
18755
|
#completionStartTime;
|
|
18756
|
+
/** When true, step-finish chunks don't auto-close the step span (for durable execution) */
|
|
18757
|
+
#deferStepClose = false;
|
|
18758
|
+
/** Stored step-finish payload when defer mode is enabled */
|
|
18759
|
+
#pendingStepFinishPayload;
|
|
18752
18760
|
constructor(modelSpan) {
|
|
18753
18761
|
this.#modelSpan = modelSpan;
|
|
18754
18762
|
}
|
|
@@ -18794,6 +18802,41 @@ var ModelSpanTracker = class {
|
|
|
18794
18802
|
updateGeneration(options) {
|
|
18795
18803
|
this.#modelSpan?.update(options);
|
|
18796
18804
|
}
|
|
18805
|
+
/**
|
|
18806
|
+
* Enable or disable deferred step closing for durable execution.
|
|
18807
|
+
* When enabled, step-finish chunks won't automatically close the step span.
|
|
18808
|
+
* Use exportCurrentStep() to get the span data, then close it manually later.
|
|
18809
|
+
*/
|
|
18810
|
+
setDeferStepClose(defer) {
|
|
18811
|
+
this.#deferStepClose = defer;
|
|
18812
|
+
}
|
|
18813
|
+
/**
|
|
18814
|
+
* Export the current step span for later rebuilding (durable execution).
|
|
18815
|
+
* Returns undefined if no step span is active.
|
|
18816
|
+
*/
|
|
18817
|
+
exportCurrentStep() {
|
|
18818
|
+
return this.#currentStepSpan?.exportSpan();
|
|
18819
|
+
}
|
|
18820
|
+
/**
|
|
18821
|
+
* Get the pending step finish payload (captured when defer mode is enabled).
|
|
18822
|
+
* This contains usage, finishReason, etc. for closing the step later.
|
|
18823
|
+
*/
|
|
18824
|
+
getPendingStepFinishPayload() {
|
|
18825
|
+
return this.#pendingStepFinishPayload;
|
|
18826
|
+
}
|
|
18827
|
+
/**
|
|
18828
|
+
* Set the starting step index for durable execution.
|
|
18829
|
+
* Used when resuming across agentic loop iterations to maintain step continuity.
|
|
18830
|
+
*/
|
|
18831
|
+
setStepIndex(index) {
|
|
18832
|
+
this.#stepIndex = index;
|
|
18833
|
+
}
|
|
18834
|
+
/**
|
|
18835
|
+
* Get the current step index.
|
|
18836
|
+
*/
|
|
18837
|
+
getStepIndex() {
|
|
18838
|
+
return this.#stepIndex;
|
|
18839
|
+
}
|
|
18797
18840
|
/**
|
|
18798
18841
|
* Start a new Model execution step.
|
|
18799
18842
|
* This should be called at the beginning of LLM execution to capture accurate startTime.
|
|
@@ -19097,7 +19140,11 @@ var ModelSpanTracker = class {
|
|
|
19097
19140
|
}
|
|
19098
19141
|
break;
|
|
19099
19142
|
case "step-finish":
|
|
19100
|
-
this.#
|
|
19143
|
+
if (this.#deferStepClose) {
|
|
19144
|
+
this.#pendingStepFinishPayload = chunk.payload;
|
|
19145
|
+
} else {
|
|
19146
|
+
this.#endStepSpan(chunk.payload);
|
|
19147
|
+
}
|
|
19101
19148
|
break;
|
|
19102
19149
|
// Infrastructure chunks - skip creating spans for these
|
|
19103
19150
|
// They are either redundant, metadata-only, or error/control flow
|
|
@@ -19216,6 +19263,7 @@ var BaseSpan = class {
|
|
|
19216
19263
|
endTime;
|
|
19217
19264
|
isEvent;
|
|
19218
19265
|
isInternal;
|
|
19266
|
+
tracingPolicy;
|
|
19219
19267
|
observabilityInstance;
|
|
19220
19268
|
input;
|
|
19221
19269
|
output;
|
|
@@ -19275,6 +19323,7 @@ var BaseSpan = class {
|
|
|
19275
19323
|
this.startTime = options.startTime ?? /* @__PURE__ */ new Date();
|
|
19276
19324
|
this.observabilityInstance = observabilityInstance;
|
|
19277
19325
|
this.isEvent = options.isEvent ?? false;
|
|
19326
|
+
this.tracingPolicy = options.tracingPolicy;
|
|
19278
19327
|
this.traceState = options.traceState;
|
|
19279
19328
|
this.tags = !options.parent && options.tags?.length ? options.tags : void 0;
|
|
19280
19329
|
const entityParent = this.getParentSpan(false);
|