@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/dist/index.js CHANGED
@@ -5134,9 +5134,14 @@ var ModelSpanTracker = class {
5134
5134
  this.#modelSpan?.update(options);
5135
5135
  }
5136
5136
  /**
5137
- * Start a new Model execution step
5137
+ * Start a new Model execution step.
5138
+ * This should be called at the beginning of LLM execution to capture accurate startTime.
5139
+ * The step-start chunk payload can be passed later via updateStep() if needed.
5138
5140
  */
5139
- #startStepSpan(payload) {
5141
+ startStep(payload) {
5142
+ if (this.#currentStepSpan) {
5143
+ return;
5144
+ }
5140
5145
  this.#currentStepSpan = this.#modelSpan?.createChildSpan({
5141
5146
  name: `step: ${this.#stepIndex}`,
5142
5147
  type: SpanType.MODEL_STEP,
@@ -5149,6 +5154,22 @@ var ModelSpanTracker = class {
5149
5154
  });
5150
5155
  this.#chunkSequence = 0;
5151
5156
  }
5157
+ /**
5158
+ * Update the current step span with additional payload data.
5159
+ * Called when step-start chunk arrives with request/warnings info.
5160
+ */
5161
+ updateStep(payload) {
5162
+ if (!this.#currentStepSpan || !payload) {
5163
+ return;
5164
+ }
5165
+ this.#currentStepSpan.update({
5166
+ input: payload.request,
5167
+ attributes: {
5168
+ ...payload.messageId ? { messageId: payload.messageId } : {},
5169
+ ...payload.warnings?.length ? { warnings: payload.warnings } : {}
5170
+ }
5171
+ });
5172
+ }
5152
5173
  /**
5153
5174
  * End the current Model execution step with token usage, finish reason, output, and metadata
5154
5175
  */
@@ -5183,7 +5204,7 @@ var ModelSpanTracker = class {
5183
5204
  */
5184
5205
  #startChunkSpan(chunkType, initialData) {
5185
5206
  if (!this.#currentStepSpan) {
5186
- this.#startStepSpan();
5207
+ this.startStep();
5187
5208
  }
5188
5209
  this.#currentChunkSpan = this.#currentStepSpan?.createChildSpan({
5189
5210
  name: `chunk: '${chunkType}'`,
@@ -5223,7 +5244,7 @@ var ModelSpanTracker = class {
5223
5244
  */
5224
5245
  #createEventSpan(chunkType, output) {
5225
5246
  if (!this.#currentStepSpan) {
5226
- this.#startStepSpan();
5247
+ this.startStep();
5227
5248
  }
5228
5249
  const span = this.#currentStepSpan?.createEventSpan({
5229
5250
  name: `chunk: '${chunkType}'`,
@@ -5342,7 +5363,7 @@ var ModelSpanTracker = class {
5342
5363
  let acc = this.#toolOutputAccumulators.get(toolCallId);
5343
5364
  if (!acc) {
5344
5365
  if (!this.#currentStepSpan) {
5345
- this.#startStepSpan();
5366
+ this.startStep();
5346
5367
  }
5347
5368
  acc = {
5348
5369
  toolName: toolName || "unknown",
@@ -5442,7 +5463,11 @@ var ModelSpanTracker = class {
5442
5463
  this.#handleObjectChunk(chunk);
5443
5464
  break;
5444
5465
  case "step-start":
5445
- this.#startStepSpan(chunk.payload);
5466
+ if (this.#currentStepSpan) {
5467
+ this.updateStep(chunk.payload);
5468
+ } else {
5469
+ this.startStep(chunk.payload);
5470
+ }
5446
5471
  break;
5447
5472
  case "step-finish":
5448
5473
  this.#endStepSpan(chunk.payload);
@@ -6426,6 +6451,9 @@ var SensitiveDataFilter = class {
6426
6451
  return "[Circular Reference]";
6427
6452
  }
6428
6453
  seen.add(obj);
6454
+ if (obj instanceof Date) {
6455
+ return obj;
6456
+ }
6429
6457
  if (Array.isArray(obj)) {
6430
6458
  return obj.map((item) => this.deepFilter(item, seen));
6431
6459
  }