@mastra/observability 0.0.0-fix-local-pkg-cwd-20251226155239 → 0.0.0-fix-11640-persist-workflow-events-to-memory-20260106220027
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 +56 -3
- package/dist/config.d.ts +105 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/index.cjs +78 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +77 -24
- package/dist/index.js.map +1 -1
- package/dist/instances/base.d.ts.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/dist/spans/base.d.ts +3 -0
- package/dist/spans/base.d.ts.map +1 -1
- package/dist/spans/serialization.d.ts +10 -0
- package/dist/spans/serialization.d.ts.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -3837,7 +3837,7 @@ ZodNaN.create = (params) => {
|
|
|
3837
3837
|
...processCreateParams(params)
|
|
3838
3838
|
});
|
|
3839
3839
|
};
|
|
3840
|
-
var BRAND = Symbol("zod_brand");
|
|
3840
|
+
var BRAND = /* @__PURE__ */ Symbol("zod_brand");
|
|
3841
3841
|
var ZodBranded = class extends ZodType {
|
|
3842
3842
|
_parse(input) {
|
|
3843
3843
|
const { ctx } = this._processInputParams(input);
|
|
@@ -4074,6 +4074,12 @@ var samplingStrategySchema = external_exports.discriminatedUnion("type", [
|
|
|
4074
4074
|
sampler: external_exports.function().args(external_exports.any().optional()).returns(external_exports.boolean())
|
|
4075
4075
|
})
|
|
4076
4076
|
]);
|
|
4077
|
+
var serializationOptionsSchema = external_exports.object({
|
|
4078
|
+
maxStringLength: external_exports.number().int().positive().optional(),
|
|
4079
|
+
maxDepth: external_exports.number().int().positive().optional(),
|
|
4080
|
+
maxArrayLength: external_exports.number().int().positive().optional(),
|
|
4081
|
+
maxObjectKeys: external_exports.number().int().positive().optional()
|
|
4082
|
+
}).optional();
|
|
4077
4083
|
var observabilityInstanceConfigSchema = external_exports.object({
|
|
4078
4084
|
name: external_exports.string().min(1, "Name is required"),
|
|
4079
4085
|
serviceName: external_exports.string().min(1, "Service name is required"),
|
|
@@ -4082,7 +4088,8 @@ var observabilityInstanceConfigSchema = external_exports.object({
|
|
|
4082
4088
|
bridge: external_exports.any().optional(),
|
|
4083
4089
|
spanOutputProcessors: external_exports.array(external_exports.any()).optional(),
|
|
4084
4090
|
includeInternalSpans: external_exports.boolean().optional(),
|
|
4085
|
-
requestContextKeys: external_exports.array(external_exports.string()).optional()
|
|
4091
|
+
requestContextKeys: external_exports.array(external_exports.string()).optional(),
|
|
4092
|
+
serializationOptions: serializationOptionsSchema
|
|
4086
4093
|
}).refine(
|
|
4087
4094
|
(data) => {
|
|
4088
4095
|
const hasExporters = data.exporters && data.exporters.length > 0;
|
|
@@ -4100,7 +4107,8 @@ var observabilityConfigValueSchema = external_exports.object({
|
|
|
4100
4107
|
bridge: external_exports.any().optional(),
|
|
4101
4108
|
spanOutputProcessors: external_exports.array(external_exports.any()).optional(),
|
|
4102
4109
|
includeInternalSpans: external_exports.boolean().optional(),
|
|
4103
|
-
requestContextKeys: external_exports.array(external_exports.string()).optional()
|
|
4110
|
+
requestContextKeys: external_exports.array(external_exports.string()).optional(),
|
|
4111
|
+
serializationOptions: serializationOptionsSchema
|
|
4104
4112
|
}).refine(
|
|
4105
4113
|
(data) => {
|
|
4106
4114
|
const hasExporters = data.exporters && data.exporters.length > 0;
|
|
@@ -5134,9 +5142,14 @@ var ModelSpanTracker = class {
|
|
|
5134
5142
|
this.#modelSpan?.update(options);
|
|
5135
5143
|
}
|
|
5136
5144
|
/**
|
|
5137
|
-
* Start a new Model execution step
|
|
5145
|
+
* Start a new Model execution step.
|
|
5146
|
+
* This should be called at the beginning of LLM execution to capture accurate startTime.
|
|
5147
|
+
* The step-start chunk payload can be passed later via updateStep() if needed.
|
|
5138
5148
|
*/
|
|
5139
|
-
|
|
5149
|
+
startStep(payload) {
|
|
5150
|
+
if (this.#currentStepSpan) {
|
|
5151
|
+
return;
|
|
5152
|
+
}
|
|
5140
5153
|
this.#currentStepSpan = this.#modelSpan?.createChildSpan({
|
|
5141
5154
|
name: `step: ${this.#stepIndex}`,
|
|
5142
5155
|
type: SpanType.MODEL_STEP,
|
|
@@ -5149,6 +5162,22 @@ var ModelSpanTracker = class {
|
|
|
5149
5162
|
});
|
|
5150
5163
|
this.#chunkSequence = 0;
|
|
5151
5164
|
}
|
|
5165
|
+
/**
|
|
5166
|
+
* Update the current step span with additional payload data.
|
|
5167
|
+
* Called when step-start chunk arrives with request/warnings info.
|
|
5168
|
+
*/
|
|
5169
|
+
updateStep(payload) {
|
|
5170
|
+
if (!this.#currentStepSpan || !payload) {
|
|
5171
|
+
return;
|
|
5172
|
+
}
|
|
5173
|
+
this.#currentStepSpan.update({
|
|
5174
|
+
input: payload.request,
|
|
5175
|
+
attributes: {
|
|
5176
|
+
...payload.messageId ? { messageId: payload.messageId } : {},
|
|
5177
|
+
...payload.warnings?.length ? { warnings: payload.warnings } : {}
|
|
5178
|
+
}
|
|
5179
|
+
});
|
|
5180
|
+
}
|
|
5152
5181
|
/**
|
|
5153
5182
|
* End the current Model execution step with token usage, finish reason, output, and metadata
|
|
5154
5183
|
*/
|
|
@@ -5183,7 +5212,7 @@ var ModelSpanTracker = class {
|
|
|
5183
5212
|
*/
|
|
5184
5213
|
#startChunkSpan(chunkType, initialData) {
|
|
5185
5214
|
if (!this.#currentStepSpan) {
|
|
5186
|
-
this
|
|
5215
|
+
this.startStep();
|
|
5187
5216
|
}
|
|
5188
5217
|
this.#currentChunkSpan = this.#currentStepSpan?.createChildSpan({
|
|
5189
5218
|
name: `chunk: '${chunkType}'`,
|
|
@@ -5223,7 +5252,7 @@ var ModelSpanTracker = class {
|
|
|
5223
5252
|
*/
|
|
5224
5253
|
#createEventSpan(chunkType, output) {
|
|
5225
5254
|
if (!this.#currentStepSpan) {
|
|
5226
|
-
this
|
|
5255
|
+
this.startStep();
|
|
5227
5256
|
}
|
|
5228
5257
|
const span = this.#currentStepSpan?.createEventSpan({
|
|
5229
5258
|
name: `chunk: '${chunkType}'`,
|
|
@@ -5342,7 +5371,7 @@ var ModelSpanTracker = class {
|
|
|
5342
5371
|
let acc = this.#toolOutputAccumulators.get(toolCallId);
|
|
5343
5372
|
if (!acc) {
|
|
5344
5373
|
if (!this.#currentStepSpan) {
|
|
5345
|
-
this
|
|
5374
|
+
this.startStep();
|
|
5346
5375
|
}
|
|
5347
5376
|
acc = {
|
|
5348
5377
|
toolName: toolName || "unknown",
|
|
@@ -5442,7 +5471,11 @@ var ModelSpanTracker = class {
|
|
|
5442
5471
|
this.#handleObjectChunk(chunk);
|
|
5443
5472
|
break;
|
|
5444
5473
|
case "step-start":
|
|
5445
|
-
this.#
|
|
5474
|
+
if (this.#currentStepSpan) {
|
|
5475
|
+
this.updateStep(chunk.payload);
|
|
5476
|
+
} else {
|
|
5477
|
+
this.startStep(chunk.payload);
|
|
5478
|
+
}
|
|
5446
5479
|
break;
|
|
5447
5480
|
case "step-finish":
|
|
5448
5481
|
this.#endStepSpan(chunk.payload);
|
|
@@ -5501,6 +5534,18 @@ var DEFAULT_DEEP_CLEAN_OPTIONS = Object.freeze({
|
|
|
5501
5534
|
maxArrayLength: 50,
|
|
5502
5535
|
maxObjectKeys: 50
|
|
5503
5536
|
});
|
|
5537
|
+
function mergeSerializationOptions(userOptions) {
|
|
5538
|
+
if (!userOptions) {
|
|
5539
|
+
return DEFAULT_DEEP_CLEAN_OPTIONS;
|
|
5540
|
+
}
|
|
5541
|
+
return {
|
|
5542
|
+
keysToStrip: DEFAULT_KEYS_TO_STRIP,
|
|
5543
|
+
maxDepth: userOptions.maxDepth ?? DEFAULT_DEEP_CLEAN_OPTIONS.maxDepth,
|
|
5544
|
+
maxStringLength: userOptions.maxStringLength ?? DEFAULT_DEEP_CLEAN_OPTIONS.maxStringLength,
|
|
5545
|
+
maxArrayLength: userOptions.maxArrayLength ?? DEFAULT_DEEP_CLEAN_OPTIONS.maxArrayLength,
|
|
5546
|
+
maxObjectKeys: userOptions.maxObjectKeys ?? DEFAULT_DEEP_CLEAN_OPTIONS.maxObjectKeys
|
|
5547
|
+
};
|
|
5548
|
+
}
|
|
5504
5549
|
function truncateString(s, maxChars) {
|
|
5505
5550
|
if (s.length <= maxChars) {
|
|
5506
5551
|
return s;
|
|
@@ -5657,11 +5702,15 @@ var BaseSpan = class {
|
|
|
5657
5702
|
entityName;
|
|
5658
5703
|
/** Parent span ID (for root spans that are children of external spans) */
|
|
5659
5704
|
parentSpanId;
|
|
5705
|
+
/** Deep clean options for serialization */
|
|
5706
|
+
deepCleanOptions;
|
|
5660
5707
|
constructor(options, observabilityInstance) {
|
|
5708
|
+
const serializationOptions = observabilityInstance.getConfig().serializationOptions;
|
|
5709
|
+
this.deepCleanOptions = mergeSerializationOptions(serializationOptions);
|
|
5661
5710
|
this.name = options.name;
|
|
5662
5711
|
this.type = options.type;
|
|
5663
|
-
this.attributes = deepClean(options.attributes) || {};
|
|
5664
|
-
this.metadata = deepClean(options.metadata);
|
|
5712
|
+
this.attributes = deepClean(options.attributes, this.deepCleanOptions) || {};
|
|
5713
|
+
this.metadata = deepClean(options.metadata, this.deepCleanOptions);
|
|
5665
5714
|
this.parent = options.parent;
|
|
5666
5715
|
this.startTime = /* @__PURE__ */ new Date();
|
|
5667
5716
|
this.observabilityInstance = observabilityInstance;
|
|
@@ -5673,9 +5722,9 @@ var BaseSpan = class {
|
|
|
5673
5722
|
this.entityId = options.entityId;
|
|
5674
5723
|
this.entityName = options.entityName;
|
|
5675
5724
|
if (this.isEvent) {
|
|
5676
|
-
this.output = deepClean(options.output);
|
|
5725
|
+
this.output = deepClean(options.output, this.deepCleanOptions);
|
|
5677
5726
|
} else {
|
|
5678
|
-
this.input = deepClean(options.input);
|
|
5727
|
+
this.input = deepClean(options.input, this.deepCleanOptions);
|
|
5679
5728
|
}
|
|
5680
5729
|
}
|
|
5681
5730
|
createChildSpan(options) {
|
|
@@ -5807,13 +5856,13 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
5807
5856
|
}
|
|
5808
5857
|
this.endTime = /* @__PURE__ */ new Date();
|
|
5809
5858
|
if (options?.output !== void 0) {
|
|
5810
|
-
this.output = deepClean(options.output);
|
|
5859
|
+
this.output = deepClean(options.output, this.deepCleanOptions);
|
|
5811
5860
|
}
|
|
5812
5861
|
if (options?.attributes) {
|
|
5813
|
-
this.attributes = { ...this.attributes, ...deepClean(options.attributes) };
|
|
5862
|
+
this.attributes = { ...this.attributes, ...deepClean(options.attributes, this.deepCleanOptions) };
|
|
5814
5863
|
}
|
|
5815
5864
|
if (options?.metadata) {
|
|
5816
|
-
this.metadata = { ...this.metadata, ...deepClean(options.metadata) };
|
|
5865
|
+
this.metadata = { ...this.metadata, ...deepClean(options.metadata, this.deepCleanOptions) };
|
|
5817
5866
|
}
|
|
5818
5867
|
}
|
|
5819
5868
|
error(options) {
|
|
@@ -5831,10 +5880,10 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
5831
5880
|
message: error.message
|
|
5832
5881
|
};
|
|
5833
5882
|
if (attributes) {
|
|
5834
|
-
this.attributes = { ...this.attributes, ...deepClean(attributes) };
|
|
5883
|
+
this.attributes = { ...this.attributes, ...deepClean(attributes, this.deepCleanOptions) };
|
|
5835
5884
|
}
|
|
5836
5885
|
if (metadata) {
|
|
5837
|
-
this.metadata = { ...this.metadata, ...deepClean(metadata) };
|
|
5886
|
+
this.metadata = { ...this.metadata, ...deepClean(metadata, this.deepCleanOptions) };
|
|
5838
5887
|
}
|
|
5839
5888
|
if (endSpan) {
|
|
5840
5889
|
this.end();
|
|
@@ -5847,16 +5896,16 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
5847
5896
|
return;
|
|
5848
5897
|
}
|
|
5849
5898
|
if (options.input !== void 0) {
|
|
5850
|
-
this.input = deepClean(options.input);
|
|
5899
|
+
this.input = deepClean(options.input, this.deepCleanOptions);
|
|
5851
5900
|
}
|
|
5852
5901
|
if (options.output !== void 0) {
|
|
5853
|
-
this.output = deepClean(options.output);
|
|
5902
|
+
this.output = deepClean(options.output, this.deepCleanOptions);
|
|
5854
5903
|
}
|
|
5855
5904
|
if (options.attributes) {
|
|
5856
|
-
this.attributes = { ...this.attributes, ...deepClean(options.attributes) };
|
|
5905
|
+
this.attributes = { ...this.attributes, ...deepClean(options.attributes, this.deepCleanOptions) };
|
|
5857
5906
|
}
|
|
5858
5907
|
if (options.metadata) {
|
|
5859
|
-
this.metadata = { ...this.metadata, ...deepClean(options.metadata) };
|
|
5908
|
+
this.metadata = { ...this.metadata, ...deepClean(options.metadata, this.deepCleanOptions) };
|
|
5860
5909
|
}
|
|
5861
5910
|
}
|
|
5862
5911
|
get isValid() {
|
|
@@ -5947,7 +5996,8 @@ var BaseObservabilityInstance = class extends MastraBase {
|
|
|
5947
5996
|
spanOutputProcessors: config.spanOutputProcessors ?? [],
|
|
5948
5997
|
bridge: config.bridge ?? void 0,
|
|
5949
5998
|
includeInternalSpans: config.includeInternalSpans ?? false,
|
|
5950
|
-
requestContextKeys: config.requestContextKeys ?? []
|
|
5999
|
+
requestContextKeys: config.requestContextKeys ?? [],
|
|
6000
|
+
serializationOptions: config.serializationOptions
|
|
5951
6001
|
};
|
|
5952
6002
|
if (this.config.bridge?.init) {
|
|
5953
6003
|
this.config.bridge.init({ config: this.config });
|
|
@@ -6426,6 +6476,9 @@ var SensitiveDataFilter = class {
|
|
|
6426
6476
|
return "[Circular Reference]";
|
|
6427
6477
|
}
|
|
6428
6478
|
seen.add(obj);
|
|
6479
|
+
if (obj instanceof Date) {
|
|
6480
|
+
return obj;
|
|
6481
|
+
}
|
|
6429
6482
|
if (Array.isArray(obj)) {
|
|
6430
6483
|
return obj.map((item) => this.deepFilter(item, seen));
|
|
6431
6484
|
}
|
|
@@ -6645,6 +6698,6 @@ function buildTracingOptions(...updaters) {
|
|
|
6645
6698
|
return updaters.reduce((opts, updater) => updater(opts), {});
|
|
6646
6699
|
}
|
|
6647
6700
|
|
|
6648
|
-
export { BaseExporter, BaseObservabilityInstance, BaseSpan, CloudExporter, ConsoleExporter, DEFAULT_DEEP_CLEAN_OPTIONS, DEFAULT_KEYS_TO_STRIP, DefaultExporter, DefaultObservabilityInstance, DefaultSpan, ModelSpanTracker, NoOpSpan, Observability, SamplingStrategyType, SensitiveDataFilter, TestExporter, buildTracingOptions, deepClean, getExternalParentId, observabilityConfigValueSchema, observabilityInstanceConfigSchema, observabilityRegistryConfigSchema, samplingStrategySchema, truncateString };
|
|
6701
|
+
export { BaseExporter, BaseObservabilityInstance, BaseSpan, CloudExporter, ConsoleExporter, DEFAULT_DEEP_CLEAN_OPTIONS, DEFAULT_KEYS_TO_STRIP, DefaultExporter, DefaultObservabilityInstance, DefaultSpan, ModelSpanTracker, NoOpSpan, Observability, SamplingStrategyType, SensitiveDataFilter, TestExporter, buildTracingOptions, deepClean, getExternalParentId, mergeSerializationOptions, observabilityConfigValueSchema, observabilityInstanceConfigSchema, observabilityRegistryConfigSchema, samplingStrategySchema, serializationOptionsSchema, truncateString };
|
|
6649
6702
|
//# sourceMappingURL=index.js.map
|
|
6650
6703
|
//# sourceMappingURL=index.js.map
|