@mastra/observability 0.0.0-fix-local-pkg-cwd-20251224015404 → 0.0.0-jail-fs-20260105160110
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 +8 -8
package/dist/index.cjs
CHANGED
|
@@ -3839,7 +3839,7 @@ ZodNaN.create = (params) => {
|
|
|
3839
3839
|
...processCreateParams(params)
|
|
3840
3840
|
});
|
|
3841
3841
|
};
|
|
3842
|
-
var BRAND = Symbol("zod_brand");
|
|
3842
|
+
var BRAND = /* @__PURE__ */ Symbol("zod_brand");
|
|
3843
3843
|
var ZodBranded = class extends ZodType {
|
|
3844
3844
|
_parse(input) {
|
|
3845
3845
|
const { ctx } = this._processInputParams(input);
|
|
@@ -4076,6 +4076,12 @@ var samplingStrategySchema = external_exports.discriminatedUnion("type", [
|
|
|
4076
4076
|
sampler: external_exports.function().args(external_exports.any().optional()).returns(external_exports.boolean())
|
|
4077
4077
|
})
|
|
4078
4078
|
]);
|
|
4079
|
+
var serializationOptionsSchema = external_exports.object({
|
|
4080
|
+
maxStringLength: external_exports.number().int().positive().optional(),
|
|
4081
|
+
maxDepth: external_exports.number().int().positive().optional(),
|
|
4082
|
+
maxArrayLength: external_exports.number().int().positive().optional(),
|
|
4083
|
+
maxObjectKeys: external_exports.number().int().positive().optional()
|
|
4084
|
+
}).optional();
|
|
4079
4085
|
var observabilityInstanceConfigSchema = external_exports.object({
|
|
4080
4086
|
name: external_exports.string().min(1, "Name is required"),
|
|
4081
4087
|
serviceName: external_exports.string().min(1, "Service name is required"),
|
|
@@ -4084,7 +4090,8 @@ var observabilityInstanceConfigSchema = external_exports.object({
|
|
|
4084
4090
|
bridge: external_exports.any().optional(),
|
|
4085
4091
|
spanOutputProcessors: external_exports.array(external_exports.any()).optional(),
|
|
4086
4092
|
includeInternalSpans: external_exports.boolean().optional(),
|
|
4087
|
-
requestContextKeys: external_exports.array(external_exports.string()).optional()
|
|
4093
|
+
requestContextKeys: external_exports.array(external_exports.string()).optional(),
|
|
4094
|
+
serializationOptions: serializationOptionsSchema
|
|
4088
4095
|
}).refine(
|
|
4089
4096
|
(data) => {
|
|
4090
4097
|
const hasExporters = data.exporters && data.exporters.length > 0;
|
|
@@ -4102,7 +4109,8 @@ var observabilityConfigValueSchema = external_exports.object({
|
|
|
4102
4109
|
bridge: external_exports.any().optional(),
|
|
4103
4110
|
spanOutputProcessors: external_exports.array(external_exports.any()).optional(),
|
|
4104
4111
|
includeInternalSpans: external_exports.boolean().optional(),
|
|
4105
|
-
requestContextKeys: external_exports.array(external_exports.string()).optional()
|
|
4112
|
+
requestContextKeys: external_exports.array(external_exports.string()).optional(),
|
|
4113
|
+
serializationOptions: serializationOptionsSchema
|
|
4106
4114
|
}).refine(
|
|
4107
4115
|
(data) => {
|
|
4108
4116
|
const hasExporters = data.exporters && data.exporters.length > 0;
|
|
@@ -5136,9 +5144,14 @@ var ModelSpanTracker = class {
|
|
|
5136
5144
|
this.#modelSpan?.update(options);
|
|
5137
5145
|
}
|
|
5138
5146
|
/**
|
|
5139
|
-
* Start a new Model execution step
|
|
5147
|
+
* Start a new Model execution step.
|
|
5148
|
+
* This should be called at the beginning of LLM execution to capture accurate startTime.
|
|
5149
|
+
* The step-start chunk payload can be passed later via updateStep() if needed.
|
|
5140
5150
|
*/
|
|
5141
|
-
|
|
5151
|
+
startStep(payload) {
|
|
5152
|
+
if (this.#currentStepSpan) {
|
|
5153
|
+
return;
|
|
5154
|
+
}
|
|
5142
5155
|
this.#currentStepSpan = this.#modelSpan?.createChildSpan({
|
|
5143
5156
|
name: `step: ${this.#stepIndex}`,
|
|
5144
5157
|
type: observability.SpanType.MODEL_STEP,
|
|
@@ -5151,6 +5164,22 @@ var ModelSpanTracker = class {
|
|
|
5151
5164
|
});
|
|
5152
5165
|
this.#chunkSequence = 0;
|
|
5153
5166
|
}
|
|
5167
|
+
/**
|
|
5168
|
+
* Update the current step span with additional payload data.
|
|
5169
|
+
* Called when step-start chunk arrives with request/warnings info.
|
|
5170
|
+
*/
|
|
5171
|
+
updateStep(payload) {
|
|
5172
|
+
if (!this.#currentStepSpan || !payload) {
|
|
5173
|
+
return;
|
|
5174
|
+
}
|
|
5175
|
+
this.#currentStepSpan.update({
|
|
5176
|
+
input: payload.request,
|
|
5177
|
+
attributes: {
|
|
5178
|
+
...payload.messageId ? { messageId: payload.messageId } : {},
|
|
5179
|
+
...payload.warnings?.length ? { warnings: payload.warnings } : {}
|
|
5180
|
+
}
|
|
5181
|
+
});
|
|
5182
|
+
}
|
|
5154
5183
|
/**
|
|
5155
5184
|
* End the current Model execution step with token usage, finish reason, output, and metadata
|
|
5156
5185
|
*/
|
|
@@ -5185,7 +5214,7 @@ var ModelSpanTracker = class {
|
|
|
5185
5214
|
*/
|
|
5186
5215
|
#startChunkSpan(chunkType, initialData) {
|
|
5187
5216
|
if (!this.#currentStepSpan) {
|
|
5188
|
-
this
|
|
5217
|
+
this.startStep();
|
|
5189
5218
|
}
|
|
5190
5219
|
this.#currentChunkSpan = this.#currentStepSpan?.createChildSpan({
|
|
5191
5220
|
name: `chunk: '${chunkType}'`,
|
|
@@ -5225,7 +5254,7 @@ var ModelSpanTracker = class {
|
|
|
5225
5254
|
*/
|
|
5226
5255
|
#createEventSpan(chunkType, output) {
|
|
5227
5256
|
if (!this.#currentStepSpan) {
|
|
5228
|
-
this
|
|
5257
|
+
this.startStep();
|
|
5229
5258
|
}
|
|
5230
5259
|
const span = this.#currentStepSpan?.createEventSpan({
|
|
5231
5260
|
name: `chunk: '${chunkType}'`,
|
|
@@ -5344,7 +5373,7 @@ var ModelSpanTracker = class {
|
|
|
5344
5373
|
let acc = this.#toolOutputAccumulators.get(toolCallId);
|
|
5345
5374
|
if (!acc) {
|
|
5346
5375
|
if (!this.#currentStepSpan) {
|
|
5347
|
-
this
|
|
5376
|
+
this.startStep();
|
|
5348
5377
|
}
|
|
5349
5378
|
acc = {
|
|
5350
5379
|
toolName: toolName || "unknown",
|
|
@@ -5444,7 +5473,11 @@ var ModelSpanTracker = class {
|
|
|
5444
5473
|
this.#handleObjectChunk(chunk);
|
|
5445
5474
|
break;
|
|
5446
5475
|
case "step-start":
|
|
5447
|
-
this.#
|
|
5476
|
+
if (this.#currentStepSpan) {
|
|
5477
|
+
this.updateStep(chunk.payload);
|
|
5478
|
+
} else {
|
|
5479
|
+
this.startStep(chunk.payload);
|
|
5480
|
+
}
|
|
5448
5481
|
break;
|
|
5449
5482
|
case "step-finish":
|
|
5450
5483
|
this.#endStepSpan(chunk.payload);
|
|
@@ -5503,6 +5536,18 @@ var DEFAULT_DEEP_CLEAN_OPTIONS = Object.freeze({
|
|
|
5503
5536
|
maxArrayLength: 50,
|
|
5504
5537
|
maxObjectKeys: 50
|
|
5505
5538
|
});
|
|
5539
|
+
function mergeSerializationOptions(userOptions) {
|
|
5540
|
+
if (!userOptions) {
|
|
5541
|
+
return DEFAULT_DEEP_CLEAN_OPTIONS;
|
|
5542
|
+
}
|
|
5543
|
+
return {
|
|
5544
|
+
keysToStrip: DEFAULT_KEYS_TO_STRIP,
|
|
5545
|
+
maxDepth: userOptions.maxDepth ?? DEFAULT_DEEP_CLEAN_OPTIONS.maxDepth,
|
|
5546
|
+
maxStringLength: userOptions.maxStringLength ?? DEFAULT_DEEP_CLEAN_OPTIONS.maxStringLength,
|
|
5547
|
+
maxArrayLength: userOptions.maxArrayLength ?? DEFAULT_DEEP_CLEAN_OPTIONS.maxArrayLength,
|
|
5548
|
+
maxObjectKeys: userOptions.maxObjectKeys ?? DEFAULT_DEEP_CLEAN_OPTIONS.maxObjectKeys
|
|
5549
|
+
};
|
|
5550
|
+
}
|
|
5506
5551
|
function truncateString(s, maxChars) {
|
|
5507
5552
|
if (s.length <= maxChars) {
|
|
5508
5553
|
return s;
|
|
@@ -5659,11 +5704,15 @@ var BaseSpan = class {
|
|
|
5659
5704
|
entityName;
|
|
5660
5705
|
/** Parent span ID (for root spans that are children of external spans) */
|
|
5661
5706
|
parentSpanId;
|
|
5707
|
+
/** Deep clean options for serialization */
|
|
5708
|
+
deepCleanOptions;
|
|
5662
5709
|
constructor(options, observabilityInstance) {
|
|
5710
|
+
const serializationOptions = observabilityInstance.getConfig().serializationOptions;
|
|
5711
|
+
this.deepCleanOptions = mergeSerializationOptions(serializationOptions);
|
|
5663
5712
|
this.name = options.name;
|
|
5664
5713
|
this.type = options.type;
|
|
5665
|
-
this.attributes = deepClean(options.attributes) || {};
|
|
5666
|
-
this.metadata = deepClean(options.metadata);
|
|
5714
|
+
this.attributes = deepClean(options.attributes, this.deepCleanOptions) || {};
|
|
5715
|
+
this.metadata = deepClean(options.metadata, this.deepCleanOptions);
|
|
5667
5716
|
this.parent = options.parent;
|
|
5668
5717
|
this.startTime = /* @__PURE__ */ new Date();
|
|
5669
5718
|
this.observabilityInstance = observabilityInstance;
|
|
@@ -5675,9 +5724,9 @@ var BaseSpan = class {
|
|
|
5675
5724
|
this.entityId = options.entityId;
|
|
5676
5725
|
this.entityName = options.entityName;
|
|
5677
5726
|
if (this.isEvent) {
|
|
5678
|
-
this.output = deepClean(options.output);
|
|
5727
|
+
this.output = deepClean(options.output, this.deepCleanOptions);
|
|
5679
5728
|
} else {
|
|
5680
|
-
this.input = deepClean(options.input);
|
|
5729
|
+
this.input = deepClean(options.input, this.deepCleanOptions);
|
|
5681
5730
|
}
|
|
5682
5731
|
}
|
|
5683
5732
|
createChildSpan(options) {
|
|
@@ -5809,13 +5858,13 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
5809
5858
|
}
|
|
5810
5859
|
this.endTime = /* @__PURE__ */ new Date();
|
|
5811
5860
|
if (options?.output !== void 0) {
|
|
5812
|
-
this.output = deepClean(options.output);
|
|
5861
|
+
this.output = deepClean(options.output, this.deepCleanOptions);
|
|
5813
5862
|
}
|
|
5814
5863
|
if (options?.attributes) {
|
|
5815
|
-
this.attributes = { ...this.attributes, ...deepClean(options.attributes) };
|
|
5864
|
+
this.attributes = { ...this.attributes, ...deepClean(options.attributes, this.deepCleanOptions) };
|
|
5816
5865
|
}
|
|
5817
5866
|
if (options?.metadata) {
|
|
5818
|
-
this.metadata = { ...this.metadata, ...deepClean(options.metadata) };
|
|
5867
|
+
this.metadata = { ...this.metadata, ...deepClean(options.metadata, this.deepCleanOptions) };
|
|
5819
5868
|
}
|
|
5820
5869
|
}
|
|
5821
5870
|
error(options) {
|
|
@@ -5833,10 +5882,10 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
5833
5882
|
message: error$1.message
|
|
5834
5883
|
};
|
|
5835
5884
|
if (attributes) {
|
|
5836
|
-
this.attributes = { ...this.attributes, ...deepClean(attributes) };
|
|
5885
|
+
this.attributes = { ...this.attributes, ...deepClean(attributes, this.deepCleanOptions) };
|
|
5837
5886
|
}
|
|
5838
5887
|
if (metadata) {
|
|
5839
|
-
this.metadata = { ...this.metadata, ...deepClean(metadata) };
|
|
5888
|
+
this.metadata = { ...this.metadata, ...deepClean(metadata, this.deepCleanOptions) };
|
|
5840
5889
|
}
|
|
5841
5890
|
if (endSpan) {
|
|
5842
5891
|
this.end();
|
|
@@ -5849,16 +5898,16 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
5849
5898
|
return;
|
|
5850
5899
|
}
|
|
5851
5900
|
if (options.input !== void 0) {
|
|
5852
|
-
this.input = deepClean(options.input);
|
|
5901
|
+
this.input = deepClean(options.input, this.deepCleanOptions);
|
|
5853
5902
|
}
|
|
5854
5903
|
if (options.output !== void 0) {
|
|
5855
|
-
this.output = deepClean(options.output);
|
|
5904
|
+
this.output = deepClean(options.output, this.deepCleanOptions);
|
|
5856
5905
|
}
|
|
5857
5906
|
if (options.attributes) {
|
|
5858
|
-
this.attributes = { ...this.attributes, ...deepClean(options.attributes) };
|
|
5907
|
+
this.attributes = { ...this.attributes, ...deepClean(options.attributes, this.deepCleanOptions) };
|
|
5859
5908
|
}
|
|
5860
5909
|
if (options.metadata) {
|
|
5861
|
-
this.metadata = { ...this.metadata, ...deepClean(options.metadata) };
|
|
5910
|
+
this.metadata = { ...this.metadata, ...deepClean(options.metadata, this.deepCleanOptions) };
|
|
5862
5911
|
}
|
|
5863
5912
|
}
|
|
5864
5913
|
get isValid() {
|
|
@@ -5949,7 +5998,8 @@ var BaseObservabilityInstance = class extends base.MastraBase {
|
|
|
5949
5998
|
spanOutputProcessors: config.spanOutputProcessors ?? [],
|
|
5950
5999
|
bridge: config.bridge ?? void 0,
|
|
5951
6000
|
includeInternalSpans: config.includeInternalSpans ?? false,
|
|
5952
|
-
requestContextKeys: config.requestContextKeys ?? []
|
|
6001
|
+
requestContextKeys: config.requestContextKeys ?? [],
|
|
6002
|
+
serializationOptions: config.serializationOptions
|
|
5953
6003
|
};
|
|
5954
6004
|
if (this.config.bridge?.init) {
|
|
5955
6005
|
this.config.bridge.init({ config: this.config });
|
|
@@ -6428,6 +6478,9 @@ var SensitiveDataFilter = class {
|
|
|
6428
6478
|
return "[Circular Reference]";
|
|
6429
6479
|
}
|
|
6430
6480
|
seen.add(obj);
|
|
6481
|
+
if (obj instanceof Date) {
|
|
6482
|
+
return obj;
|
|
6483
|
+
}
|
|
6431
6484
|
if (Array.isArray(obj)) {
|
|
6432
6485
|
return obj.map((item) => this.deepFilter(item, seen));
|
|
6433
6486
|
}
|
|
@@ -6666,10 +6719,12 @@ exports.TestExporter = TestExporter;
|
|
|
6666
6719
|
exports.buildTracingOptions = buildTracingOptions;
|
|
6667
6720
|
exports.deepClean = deepClean;
|
|
6668
6721
|
exports.getExternalParentId = getExternalParentId;
|
|
6722
|
+
exports.mergeSerializationOptions = mergeSerializationOptions;
|
|
6669
6723
|
exports.observabilityConfigValueSchema = observabilityConfigValueSchema;
|
|
6670
6724
|
exports.observabilityInstanceConfigSchema = observabilityInstanceConfigSchema;
|
|
6671
6725
|
exports.observabilityRegistryConfigSchema = observabilityRegistryConfigSchema;
|
|
6672
6726
|
exports.samplingStrategySchema = samplingStrategySchema;
|
|
6727
|
+
exports.serializationOptionsSchema = serializationOptionsSchema;
|
|
6673
6728
|
exports.truncateString = truncateString;
|
|
6674
6729
|
//# sourceMappingURL=index.cjs.map
|
|
6675
6730
|
//# sourceMappingURL=index.cjs.map
|