@mastra/observability 1.0.0-beta.7 → 1.0.0-beta.9
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 +28 -0
- package/dist/index.cjs +34 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -6
- package/dist/index.js.map +1 -1
- package/dist/model-tracing.d.ts +12 -0
- package/dist/model-tracing.d.ts.map +1 -1
- package/dist/span_processors/sensitive-data-filter.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @mastra/observability
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix SensitiveDataFilter destroying Date objects ([#11437](https://github.com/mastra-ai/mastra/pull/11437))
|
|
8
|
+
|
|
9
|
+
The `deepFilter` method now correctly preserves `Date` objects instead of converting them to empty objects `{}`. This fixes issues with downstream exporters like `BraintrustExporter` that rely on `Date` methods like `getTime()`.
|
|
10
|
+
|
|
11
|
+
Previously, `Object.keys(new Date())` returned `[]`, causing Date objects to be incorrectly converted to `{}`. The fix adds an explicit check for `Date` instances before generic object processing.
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`5947fcd`](https://github.com/mastra-ai/mastra/commit/5947fcdd425531f29f9422026d466c2ee3113c93)]:
|
|
14
|
+
- @mastra/core@1.0.0-beta.18
|
|
15
|
+
|
|
16
|
+
## 1.0.0-beta.8
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- fix(observability): start MODEL_STEP span at beginning of LLM execution ([#11409](https://github.com/mastra-ai/mastra/pull/11409))
|
|
21
|
+
|
|
22
|
+
The MODEL_STEP span was being created when the step-start chunk arrived (after the model API call completed), causing the span's startTime to be close to its endTime instead of accurately reflecting when the step began.
|
|
23
|
+
|
|
24
|
+
This fix ensures MODEL_STEP spans capture the full duration of each LLM execution step, including the API call latency, by starting the span at the beginning of the step execution rather than when the response starts streaming.
|
|
25
|
+
|
|
26
|
+
Fixes #11271
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [[`3d93a15`](https://github.com/mastra-ai/mastra/commit/3d93a15796b158c617461c8b98bede476ebb43e2), [`efe406a`](https://github.com/mastra-ai/mastra/commit/efe406a1353c24993280ebc2ed61dd9f65b84b26), [`119e5c6`](https://github.com/mastra-ai/mastra/commit/119e5c65008f3e5cfca954eefc2eb85e3bf40da4), [`74e504a`](https://github.com/mastra-ai/mastra/commit/74e504a3b584eafd2f198001c6a113bbec589fd3), [`e33fdbd`](https://github.com/mastra-ai/mastra/commit/e33fdbd07b33920d81e823122331b0c0bee0bb59), [`929f69c`](https://github.com/mastra-ai/mastra/commit/929f69c3436fa20dd0f0e2f7ebe8270bd82a1529), [`8a73529`](https://github.com/mastra-ai/mastra/commit/8a73529ca01187f604b1f3019d0a725ac63ae55f)]:
|
|
29
|
+
- @mastra/core@1.0.0-beta.16
|
|
30
|
+
|
|
3
31
|
## 1.0.0-beta.7
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -5136,9 +5136,14 @@ var ModelSpanTracker = class {
|
|
|
5136
5136
|
this.#modelSpan?.update(options);
|
|
5137
5137
|
}
|
|
5138
5138
|
/**
|
|
5139
|
-
* Start a new Model execution step
|
|
5139
|
+
* Start a new Model execution step.
|
|
5140
|
+
* This should be called at the beginning of LLM execution to capture accurate startTime.
|
|
5141
|
+
* The step-start chunk payload can be passed later via updateStep() if needed.
|
|
5140
5142
|
*/
|
|
5141
|
-
|
|
5143
|
+
startStep(payload) {
|
|
5144
|
+
if (this.#currentStepSpan) {
|
|
5145
|
+
return;
|
|
5146
|
+
}
|
|
5142
5147
|
this.#currentStepSpan = this.#modelSpan?.createChildSpan({
|
|
5143
5148
|
name: `step: ${this.#stepIndex}`,
|
|
5144
5149
|
type: observability.SpanType.MODEL_STEP,
|
|
@@ -5151,6 +5156,22 @@ var ModelSpanTracker = class {
|
|
|
5151
5156
|
});
|
|
5152
5157
|
this.#chunkSequence = 0;
|
|
5153
5158
|
}
|
|
5159
|
+
/**
|
|
5160
|
+
* Update the current step span with additional payload data.
|
|
5161
|
+
* Called when step-start chunk arrives with request/warnings info.
|
|
5162
|
+
*/
|
|
5163
|
+
updateStep(payload) {
|
|
5164
|
+
if (!this.#currentStepSpan || !payload) {
|
|
5165
|
+
return;
|
|
5166
|
+
}
|
|
5167
|
+
this.#currentStepSpan.update({
|
|
5168
|
+
input: payload.request,
|
|
5169
|
+
attributes: {
|
|
5170
|
+
...payload.messageId ? { messageId: payload.messageId } : {},
|
|
5171
|
+
...payload.warnings?.length ? { warnings: payload.warnings } : {}
|
|
5172
|
+
}
|
|
5173
|
+
});
|
|
5174
|
+
}
|
|
5154
5175
|
/**
|
|
5155
5176
|
* End the current Model execution step with token usage, finish reason, output, and metadata
|
|
5156
5177
|
*/
|
|
@@ -5185,7 +5206,7 @@ var ModelSpanTracker = class {
|
|
|
5185
5206
|
*/
|
|
5186
5207
|
#startChunkSpan(chunkType, initialData) {
|
|
5187
5208
|
if (!this.#currentStepSpan) {
|
|
5188
|
-
this
|
|
5209
|
+
this.startStep();
|
|
5189
5210
|
}
|
|
5190
5211
|
this.#currentChunkSpan = this.#currentStepSpan?.createChildSpan({
|
|
5191
5212
|
name: `chunk: '${chunkType}'`,
|
|
@@ -5225,7 +5246,7 @@ var ModelSpanTracker = class {
|
|
|
5225
5246
|
*/
|
|
5226
5247
|
#createEventSpan(chunkType, output) {
|
|
5227
5248
|
if (!this.#currentStepSpan) {
|
|
5228
|
-
this
|
|
5249
|
+
this.startStep();
|
|
5229
5250
|
}
|
|
5230
5251
|
const span = this.#currentStepSpan?.createEventSpan({
|
|
5231
5252
|
name: `chunk: '${chunkType}'`,
|
|
@@ -5344,7 +5365,7 @@ var ModelSpanTracker = class {
|
|
|
5344
5365
|
let acc = this.#toolOutputAccumulators.get(toolCallId);
|
|
5345
5366
|
if (!acc) {
|
|
5346
5367
|
if (!this.#currentStepSpan) {
|
|
5347
|
-
this
|
|
5368
|
+
this.startStep();
|
|
5348
5369
|
}
|
|
5349
5370
|
acc = {
|
|
5350
5371
|
toolName: toolName || "unknown",
|
|
@@ -5444,7 +5465,11 @@ var ModelSpanTracker = class {
|
|
|
5444
5465
|
this.#handleObjectChunk(chunk);
|
|
5445
5466
|
break;
|
|
5446
5467
|
case "step-start":
|
|
5447
|
-
this.#
|
|
5468
|
+
if (this.#currentStepSpan) {
|
|
5469
|
+
this.updateStep(chunk.payload);
|
|
5470
|
+
} else {
|
|
5471
|
+
this.startStep(chunk.payload);
|
|
5472
|
+
}
|
|
5448
5473
|
break;
|
|
5449
5474
|
case "step-finish":
|
|
5450
5475
|
this.#endStepSpan(chunk.payload);
|
|
@@ -6428,6 +6453,9 @@ var SensitiveDataFilter = class {
|
|
|
6428
6453
|
return "[Circular Reference]";
|
|
6429
6454
|
}
|
|
6430
6455
|
seen.add(obj);
|
|
6456
|
+
if (obj instanceof Date) {
|
|
6457
|
+
return obj;
|
|
6458
|
+
}
|
|
6431
6459
|
if (Array.isArray(obj)) {
|
|
6432
6460
|
return obj.map((item) => this.deepFilter(item, seen));
|
|
6433
6461
|
}
|