@mastra/observability 1.0.0-beta.1 → 1.0.0-beta.2
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 +16 -0
- package/dist/config.d.ts +107 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/exporters/index.d.ts +1 -0
- package/dist/exporters/index.d.ts.map +1 -1
- package/dist/exporters/test.d.ts +13 -0
- package/dist/exporters/test.d.ts.map +1 -0
- package/dist/index.cjs +184 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +183 -30
- package/dist/index.js.map +1 -1
- package/dist/instances/base.d.ts +9 -5
- package/dist/instances/base.d.ts.map +1 -1
- package/dist/span_processors/sensitive-data-filter.d.ts +7 -0
- package/dist/span_processors/sensitive-data-filter.d.ts.map +1 -1
- package/dist/spans/base.d.ts +39 -0
- package/dist/spans/base.d.ts.map +1 -1
- package/dist/spans/default.d.ts.map +1 -1
- package/package.json +8 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @mastra/observability
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Adds trace tagging support to the BrainTrust and Langfuse tracing exporters. ([#10765](https://github.com/mastra-ai/mastra/pull/10765))
|
|
8
|
+
|
|
9
|
+
- Adds bidirectional integration with otel tracing via a new @mastra/otel-bridge package. ([#10482](https://github.com/mastra-ai/mastra/pull/10482))
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Fix SensitiveDataFilter to redact structured data in JSON strings ([#10776](https://github.com/mastra-ai/mastra/pull/10776))
|
|
14
|
+
- Fixed issue where SensitiveDataFilter failed to redact tool results in MODEL_STEP span input messages ([#9846](https://github.com/mastra-ai/mastra/issues/9846))
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [[`ac0d2f4`](https://github.com/mastra-ai/mastra/commit/ac0d2f4ff8831f72c1c66c2be809706d17f65789), [`1a0d3fc`](https://github.com/mastra-ai/mastra/commit/1a0d3fc811482c9c376cdf79ee615c23bae9b2d6), [`85a628b`](https://github.com/mastra-ai/mastra/commit/85a628b1224a8f64cd82ea7f033774bf22df7a7e), [`c237233`](https://github.com/mastra-ai/mastra/commit/c23723399ccedf7f5744b3f40997b79246bfbe64), [`15f9e21`](https://github.com/mastra-ai/mastra/commit/15f9e216177201ea6e3f6d0bfb063fcc0953444f), [`ff94dea`](https://github.com/mastra-ai/mastra/commit/ff94dea935f4e34545c63bcb6c29804732698809), [`5b2ff46`](https://github.com/mastra-ai/mastra/commit/5b2ff4651df70c146523a7fca773f8eb0a2272f8), [`db41688`](https://github.com/mastra-ai/mastra/commit/db4168806d007417e2e60b4f68656dca4e5f40c9), [`5ca599d`](https://github.com/mastra-ai/mastra/commit/5ca599d0bb59a1595f19f58473fcd67cc71cef58), [`bff1145`](https://github.com/mastra-ai/mastra/commit/bff114556b3cbadad9b2768488708f8ad0e91475), [`5c8ca24`](https://github.com/mastra-ai/mastra/commit/5c8ca247094e0cc2cdbd7137822fb47241f86e77), [`e191844`](https://github.com/mastra-ai/mastra/commit/e1918444ca3f80e82feef1dad506cd4ec6e2875f), [`22553f1`](https://github.com/mastra-ai/mastra/commit/22553f11c63ee5e966a9c034a349822249584691), [`7237163`](https://github.com/mastra-ai/mastra/commit/72371635dbf96a87df4b073cc48fc655afbdce3d), [`2500740`](https://github.com/mastra-ai/mastra/commit/2500740ea23da067d6e50ec71c625ab3ce275e64), [`873ecbb`](https://github.com/mastra-ai/mastra/commit/873ecbb517586aa17d2f1e99283755b3ebb2863f), [`4f9bbe5`](https://github.com/mastra-ai/mastra/commit/4f9bbe5968f42c86f4930b8193de3c3c17e5bd36), [`02e51fe`](https://github.com/mastra-ai/mastra/commit/02e51feddb3d4155cfbcc42624fd0d0970d032c0), [`8f3fa3a`](https://github.com/mastra-ai/mastra/commit/8f3fa3a652bb77da092f913ec51ae46e3a7e27dc), [`cd29ad2`](https://github.com/mastra-ai/mastra/commit/cd29ad23a255534e8191f249593849ed29160886), [`bdf4d8c`](https://github.com/mastra-ai/mastra/commit/bdf4d8cdc656d8a2c21d81834bfa3bfa70f56c16), [`854e3da`](https://github.com/mastra-ai/mastra/commit/854e3dad5daac17a91a20986399d3a51f54bf68b), [`ce18d38`](https://github.com/mastra-ai/mastra/commit/ce18d38678c65870350d123955014a8432075fd9), [`cccf9c8`](https://github.com/mastra-ai/mastra/commit/cccf9c8b2d2dfc1a5e63919395b83d78c89682a0), [`61a5705`](https://github.com/mastra-ai/mastra/commit/61a570551278b6743e64243b3ce7d73de915ca8a), [`db70a48`](https://github.com/mastra-ai/mastra/commit/db70a48aeeeeb8e5f92007e8ede52c364ce15287), [`f0fdc14`](https://github.com/mastra-ai/mastra/commit/f0fdc14ee233d619266b3d2bbdeea7d25cfc6d13), [`db18bc9`](https://github.com/mastra-ai/mastra/commit/db18bc9c3825e2c1a0ad9a183cc9935f6691bfa1), [`9b37b56`](https://github.com/mastra-ai/mastra/commit/9b37b565e1f2a76c24f728945cc740c2b09be9da), [`41a23c3`](https://github.com/mastra-ai/mastra/commit/41a23c32f9877d71810f37e24930515df2ff7a0f), [`5d171ad`](https://github.com/mastra-ai/mastra/commit/5d171ad9ef340387276b77c2bb3e83e83332d729), [`f03ae60`](https://github.com/mastra-ai/mastra/commit/f03ae60500fe350c9d828621006cdafe1975fdd8), [`d1e74a0`](https://github.com/mastra-ai/mastra/commit/d1e74a0a293866dece31022047f5dbab65a304d0), [`39e7869`](https://github.com/mastra-ai/mastra/commit/39e7869bc7d0ee391077ce291474d8a84eedccff), [`5761926`](https://github.com/mastra-ai/mastra/commit/57619260c4a2cdd598763abbacd90de594c6bc76), [`c900fdd`](https://github.com/mastra-ai/mastra/commit/c900fdd504c41348efdffb205cfe80d48c38fa33), [`604a79f`](https://github.com/mastra-ai/mastra/commit/604a79fecf276e26a54a3fe01bb94e65315d2e0e), [`887f0b4`](https://github.com/mastra-ai/mastra/commit/887f0b4746cdbd7cb7d6b17ac9f82aeb58037ea5), [`2562143`](https://github.com/mastra-ai/mastra/commit/256214336b4faa78646c9c1776612393790d8784), [`ef11a61`](https://github.com/mastra-ai/mastra/commit/ef11a61920fa0ed08a5b7ceedd192875af119749)]:
|
|
17
|
+
- @mastra/core@1.0.0-beta.6
|
|
18
|
+
|
|
3
19
|
## 1.0.0-beta.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/config.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* including tracing configs, sampling strategies, and registry setup.
|
|
6
6
|
*/
|
|
7
7
|
import type { RequestContext } from '@mastra/core/di';
|
|
8
|
-
import type { ObservabilityInstance, ObservabilityExporter, SpanOutputProcessor, ConfigSelector } from '@mastra/core/observability';
|
|
8
|
+
import type { ObservabilityInstance, ObservabilityExporter, ObservabilityBridge, SpanOutputProcessor, ConfigSelector } from '@mastra/core/observability';
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
/**
|
|
11
11
|
* Sampling strategy types
|
|
@@ -49,6 +49,8 @@ export interface ObservabilityInstanceConfig {
|
|
|
49
49
|
sampling?: SamplingStrategy;
|
|
50
50
|
/** Custom exporters */
|
|
51
51
|
exporters?: ObservabilityExporter[];
|
|
52
|
+
/** Observability bridge (e.g., OpenTelemetry bridge for context extraction) */
|
|
53
|
+
bridge?: ObservabilityBridge;
|
|
52
54
|
/** Custom span output processors */
|
|
53
55
|
spanOutputProcessors?: SpanOutputProcessor[];
|
|
54
56
|
/** Set to `true` if you want to see spans internal to the operation of mastra */
|
|
@@ -109,10 +111,10 @@ export declare const samplingStrategySchema: z.ZodDiscriminatedUnion<"type", [z.
|
|
|
109
111
|
}>]>;
|
|
110
112
|
/**
|
|
111
113
|
* Zod schema for ObservabilityInstanceConfig
|
|
112
|
-
* Note: exporters, spanOutputProcessors, and configSelector are validated as any
|
|
114
|
+
* Note: exporters, spanOutputProcessors, bridge, and configSelector are validated as any
|
|
113
115
|
* since they're complex runtime objects
|
|
114
116
|
*/
|
|
115
|
-
export declare const observabilityInstanceConfigSchema: z.ZodObject<{
|
|
117
|
+
export declare const observabilityInstanceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
116
118
|
name: z.ZodString;
|
|
117
119
|
serviceName: z.ZodString;
|
|
118
120
|
sampling: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
@@ -147,6 +149,7 @@ export declare const observabilityInstanceConfigSchema: z.ZodObject<{
|
|
|
147
149
|
sampler: (args_0: any, ...args: unknown[]) => boolean;
|
|
148
150
|
}>]>>;
|
|
149
151
|
exporters: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
152
|
+
bridge: z.ZodOptional<z.ZodAny>;
|
|
150
153
|
spanOutputProcessors: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
151
154
|
includeInternalSpans: z.ZodOptional<z.ZodBoolean>;
|
|
152
155
|
requestContextKeys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -165,6 +168,7 @@ export declare const observabilityInstanceConfigSchema: z.ZodObject<{
|
|
|
165
168
|
sampler: (args_0: any, ...args: unknown[]) => boolean;
|
|
166
169
|
} | undefined;
|
|
167
170
|
exporters?: any[] | undefined;
|
|
171
|
+
bridge?: any;
|
|
168
172
|
spanOutputProcessors?: any[] | undefined;
|
|
169
173
|
includeInternalSpans?: boolean | undefined;
|
|
170
174
|
requestContextKeys?: string[] | undefined;
|
|
@@ -183,6 +187,45 @@ export declare const observabilityInstanceConfigSchema: z.ZodObject<{
|
|
|
183
187
|
sampler: (args_0: any, ...args: unknown[]) => boolean;
|
|
184
188
|
} | undefined;
|
|
185
189
|
exporters?: any[] | undefined;
|
|
190
|
+
bridge?: any;
|
|
191
|
+
spanOutputProcessors?: any[] | undefined;
|
|
192
|
+
includeInternalSpans?: boolean | undefined;
|
|
193
|
+
requestContextKeys?: string[] | undefined;
|
|
194
|
+
}>, {
|
|
195
|
+
name: string;
|
|
196
|
+
serviceName: string;
|
|
197
|
+
sampling?: {
|
|
198
|
+
type: SamplingStrategyType.ALWAYS;
|
|
199
|
+
} | {
|
|
200
|
+
type: SamplingStrategyType.NEVER;
|
|
201
|
+
} | {
|
|
202
|
+
type: SamplingStrategyType.RATIO;
|
|
203
|
+
probability: number;
|
|
204
|
+
} | {
|
|
205
|
+
type: SamplingStrategyType.CUSTOM;
|
|
206
|
+
sampler: (args_0: any, ...args: unknown[]) => boolean;
|
|
207
|
+
} | undefined;
|
|
208
|
+
exporters?: any[] | undefined;
|
|
209
|
+
bridge?: any;
|
|
210
|
+
spanOutputProcessors?: any[] | undefined;
|
|
211
|
+
includeInternalSpans?: boolean | undefined;
|
|
212
|
+
requestContextKeys?: string[] | undefined;
|
|
213
|
+
}, {
|
|
214
|
+
name: string;
|
|
215
|
+
serviceName: string;
|
|
216
|
+
sampling?: {
|
|
217
|
+
type: SamplingStrategyType.ALWAYS;
|
|
218
|
+
} | {
|
|
219
|
+
type: SamplingStrategyType.NEVER;
|
|
220
|
+
} | {
|
|
221
|
+
type: SamplingStrategyType.RATIO;
|
|
222
|
+
probability: number;
|
|
223
|
+
} | {
|
|
224
|
+
type: SamplingStrategyType.CUSTOM;
|
|
225
|
+
sampler: (args_0: any, ...args: unknown[]) => boolean;
|
|
226
|
+
} | undefined;
|
|
227
|
+
exporters?: any[] | undefined;
|
|
228
|
+
bridge?: any;
|
|
186
229
|
spanOutputProcessors?: any[] | undefined;
|
|
187
230
|
includeInternalSpans?: boolean | undefined;
|
|
188
231
|
requestContextKeys?: string[] | undefined;
|
|
@@ -191,7 +234,7 @@ export declare const observabilityInstanceConfigSchema: z.ZodObject<{
|
|
|
191
234
|
* Zod schema for config values in the configs map
|
|
192
235
|
* This is the config object without the name field
|
|
193
236
|
*/
|
|
194
|
-
export declare const observabilityConfigValueSchema: z.ZodObject<{
|
|
237
|
+
export declare const observabilityConfigValueSchema: z.ZodEffects<z.ZodObject<{
|
|
195
238
|
serviceName: z.ZodString;
|
|
196
239
|
sampling: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
197
240
|
type: z.ZodLiteral<SamplingStrategyType.ALWAYS>;
|
|
@@ -225,6 +268,7 @@ export declare const observabilityConfigValueSchema: z.ZodObject<{
|
|
|
225
268
|
sampler: (args_0: any, ...args: unknown[]) => boolean;
|
|
226
269
|
}>]>>;
|
|
227
270
|
exporters: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
271
|
+
bridge: z.ZodOptional<z.ZodAny>;
|
|
228
272
|
spanOutputProcessors: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
229
273
|
includeInternalSpans: z.ZodOptional<z.ZodBoolean>;
|
|
230
274
|
requestContextKeys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -242,6 +286,43 @@ export declare const observabilityConfigValueSchema: z.ZodObject<{
|
|
|
242
286
|
sampler: (args_0: any, ...args: unknown[]) => boolean;
|
|
243
287
|
} | undefined;
|
|
244
288
|
exporters?: any[] | undefined;
|
|
289
|
+
bridge?: any;
|
|
290
|
+
spanOutputProcessors?: any[] | undefined;
|
|
291
|
+
includeInternalSpans?: boolean | undefined;
|
|
292
|
+
requestContextKeys?: string[] | undefined;
|
|
293
|
+
}, {
|
|
294
|
+
serviceName: string;
|
|
295
|
+
sampling?: {
|
|
296
|
+
type: SamplingStrategyType.ALWAYS;
|
|
297
|
+
} | {
|
|
298
|
+
type: SamplingStrategyType.NEVER;
|
|
299
|
+
} | {
|
|
300
|
+
type: SamplingStrategyType.RATIO;
|
|
301
|
+
probability: number;
|
|
302
|
+
} | {
|
|
303
|
+
type: SamplingStrategyType.CUSTOM;
|
|
304
|
+
sampler: (args_0: any, ...args: unknown[]) => boolean;
|
|
305
|
+
} | undefined;
|
|
306
|
+
exporters?: any[] | undefined;
|
|
307
|
+
bridge?: any;
|
|
308
|
+
spanOutputProcessors?: any[] | undefined;
|
|
309
|
+
includeInternalSpans?: boolean | undefined;
|
|
310
|
+
requestContextKeys?: string[] | undefined;
|
|
311
|
+
}>, {
|
|
312
|
+
serviceName: string;
|
|
313
|
+
sampling?: {
|
|
314
|
+
type: SamplingStrategyType.ALWAYS;
|
|
315
|
+
} | {
|
|
316
|
+
type: SamplingStrategyType.NEVER;
|
|
317
|
+
} | {
|
|
318
|
+
type: SamplingStrategyType.RATIO;
|
|
319
|
+
probability: number;
|
|
320
|
+
} | {
|
|
321
|
+
type: SamplingStrategyType.CUSTOM;
|
|
322
|
+
sampler: (args_0: any, ...args: unknown[]) => boolean;
|
|
323
|
+
} | undefined;
|
|
324
|
+
exporters?: any[] | undefined;
|
|
325
|
+
bridge?: any;
|
|
245
326
|
spanOutputProcessors?: any[] | undefined;
|
|
246
327
|
includeInternalSpans?: boolean | undefined;
|
|
247
328
|
requestContextKeys?: string[] | undefined;
|
|
@@ -259,6 +340,7 @@ export declare const observabilityConfigValueSchema: z.ZodObject<{
|
|
|
259
340
|
sampler: (args_0: any, ...args: unknown[]) => boolean;
|
|
260
341
|
} | undefined;
|
|
261
342
|
exporters?: any[] | undefined;
|
|
343
|
+
bridge?: any;
|
|
262
344
|
spanOutputProcessors?: any[] | undefined;
|
|
263
345
|
includeInternalSpans?: boolean | undefined;
|
|
264
346
|
requestContextKeys?: string[] | undefined;
|
|
@@ -269,7 +351,7 @@ export declare const observabilityConfigValueSchema: z.ZodObject<{
|
|
|
269
351
|
* both plain config objects and pre-instantiated ObservabilityInstance objects.
|
|
270
352
|
* The schema is permissive to handle edge cases gracefully (arrays, null values).
|
|
271
353
|
*/
|
|
272
|
-
export declare const observabilityRegistryConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
354
|
+
export declare const observabilityRegistryConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
273
355
|
default: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
274
356
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
275
357
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -339,5 +421,25 @@ export declare const observabilityRegistryConfigSchema: z.ZodEffects<z.ZodEffect
|
|
|
339
421
|
}>>>;
|
|
340
422
|
configs: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny, "many">, z.ZodNull]>>;
|
|
341
423
|
configSelector: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
424
|
+
}, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
|
|
425
|
+
default: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
426
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
427
|
+
}, "strip", z.ZodTypeAny, {
|
|
428
|
+
enabled?: boolean | undefined;
|
|
429
|
+
}, {
|
|
430
|
+
enabled?: boolean | undefined;
|
|
431
|
+
}>>>;
|
|
432
|
+
configs: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny, "many">, z.ZodNull]>>;
|
|
433
|
+
configSelector: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
434
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
435
|
+
default: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
436
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
437
|
+
}, "strip", z.ZodTypeAny, {
|
|
438
|
+
enabled?: boolean | undefined;
|
|
439
|
+
}, {
|
|
440
|
+
enabled?: boolean | undefined;
|
|
441
|
+
}>>>;
|
|
442
|
+
configs: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny, "many">, z.ZodNull]>>;
|
|
443
|
+
configSelector: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
342
444
|
}, z.ZodTypeAny, "passthrough">>;
|
|
343
445
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;GAEG;AACH,oBAAY,oBAAoB;IAC9B,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC;IAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,OAAO,CAAA;CAAE,CAAC;AAMhG;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,qFAAqF;IACrF,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,uBAAuB;IACvB,SAAS,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACpC,oCAAoC;IACpC,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC7C,iFAAiF;IACjF,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,qFAAqF;IACrF,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;IACF,0FAA0F;IAC1F,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,2BAA2B,EAAE,MAAM,CAAC,GAAG,qBAAqB,CAAC,CAAC;IAC5F,yEAAyE;IACzE,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAMD;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAejC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,iCAAiC
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;GAEG;AACH,oBAAY,oBAAoB;IAC9B,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC;IAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,OAAO,CAAA;CAAE,CAAC;AAMhG;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,qFAAqF;IACrF,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,uBAAuB;IACvB,SAAS,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACpC,+EAA+E;IAC/E,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,oCAAoC;IACpC,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC7C,iFAAiF;IACjF,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,qFAAqF;IACrF,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;IACF,0FAA0F;IAC1F,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,2BAA2B,EAAE,MAAM,CAAC,GAAG,qBAAqB,CAAC,CAAC;IAC5F,yEAAyE;IACzE,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAMD;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAejC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqB3C,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoBxC,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAqE3C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exporters/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,QAAQ,CAAC;AAGvB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACnD,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exporters/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,QAAQ,CAAC;AAGvB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACnD,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TracingEvent } from '@mastra/core/observability';
|
|
2
|
+
import { BaseExporter } from './base.js';
|
|
3
|
+
import type { BaseExporterConfig } from './base.js';
|
|
4
|
+
export declare class TestExporter extends BaseExporter {
|
|
5
|
+
#private;
|
|
6
|
+
name: string;
|
|
7
|
+
constructor(config?: BaseExporterConfig);
|
|
8
|
+
protected _exportTracingEvent(event: TracingEvent): Promise<void>;
|
|
9
|
+
clearEvents(): void;
|
|
10
|
+
get events(): TracingEvent[];
|
|
11
|
+
shutdown(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/exporters/test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAEjD,qBAAa,YAAa,SAAQ,YAAY;;IAC5C,IAAI,SAA2B;gBAGnB,MAAM,GAAE,kBAAuB;cAI3B,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvE,WAAW;IAIX,IAAI,MAAM,IAAI,YAAY,EAAE,CAE3B;IAEK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC"}
|
package/dist/index.cjs
CHANGED
|
@@ -37,18 +37,38 @@ var observabilityInstanceConfigSchema = zod.z.object({
|
|
|
37
37
|
serviceName: zod.z.string().min(1, "Service name is required"),
|
|
38
38
|
sampling: samplingStrategySchema.optional(),
|
|
39
39
|
exporters: zod.z.array(zod.z.any()).optional(),
|
|
40
|
+
bridge: zod.z.any().optional(),
|
|
40
41
|
spanOutputProcessors: zod.z.array(zod.z.any()).optional(),
|
|
41
42
|
includeInternalSpans: zod.z.boolean().optional(),
|
|
42
43
|
requestContextKeys: zod.z.array(zod.z.string()).optional()
|
|
43
|
-
})
|
|
44
|
+
}).refine(
|
|
45
|
+
(data) => {
|
|
46
|
+
const hasExporters = data.exporters && data.exporters.length > 0;
|
|
47
|
+
const hasBridge = !!data.bridge;
|
|
48
|
+
return hasExporters || hasBridge;
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
message: "At least one exporter or a bridge is required"
|
|
52
|
+
}
|
|
53
|
+
);
|
|
44
54
|
var observabilityConfigValueSchema = zod.z.object({
|
|
45
55
|
serviceName: zod.z.string().min(1, "Service name is required"),
|
|
46
56
|
sampling: samplingStrategySchema.optional(),
|
|
47
57
|
exporters: zod.z.array(zod.z.any()).optional(),
|
|
58
|
+
bridge: zod.z.any().optional(),
|
|
48
59
|
spanOutputProcessors: zod.z.array(zod.z.any()).optional(),
|
|
49
60
|
includeInternalSpans: zod.z.boolean().optional(),
|
|
50
61
|
requestContextKeys: zod.z.array(zod.z.string()).optional()
|
|
51
|
-
})
|
|
62
|
+
}).refine(
|
|
63
|
+
(data) => {
|
|
64
|
+
const hasExporters = data.exporters && data.exporters.length > 0;
|
|
65
|
+
const hasBridge = !!data.bridge;
|
|
66
|
+
return hasExporters || hasBridge;
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
message: "At least one exporter or a bridge is required"
|
|
70
|
+
}
|
|
71
|
+
);
|
|
52
72
|
var observabilityRegistryConfigSchema = zod.z.object({
|
|
53
73
|
default: zod.z.object({
|
|
54
74
|
enabled: zod.z.boolean().optional()
|
|
@@ -75,6 +95,18 @@ var observabilityRegistryConfigSchema = zod.z.object({
|
|
|
75
95
|
{
|
|
76
96
|
message: 'A "configSelector" function is required when multiple configs are specified to determine which config to use.'
|
|
77
97
|
}
|
|
98
|
+
).refine(
|
|
99
|
+
(data) => {
|
|
100
|
+
if (data.configSelector) {
|
|
101
|
+
const isDefaultEnabled = data.default?.enabled === true;
|
|
102
|
+
const hasConfigs = data.configs && typeof data.configs === "object" && !Array.isArray(data.configs) ? Object.keys(data.configs).length > 0 : false;
|
|
103
|
+
return isDefaultEnabled || hasConfigs;
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
message: 'A "configSelector" requires at least one config or default observability to be configured.'
|
|
109
|
+
}
|
|
78
110
|
);
|
|
79
111
|
var BaseExporter = class {
|
|
80
112
|
/** Mastra logger instance */
|
|
@@ -895,6 +927,27 @@ var DefaultExporter = class extends BaseExporter {
|
|
|
895
927
|
this.logger.info("DefaultExporter shutdown complete");
|
|
896
928
|
}
|
|
897
929
|
};
|
|
930
|
+
|
|
931
|
+
// src/exporters/test.ts
|
|
932
|
+
var TestExporter = class extends BaseExporter {
|
|
933
|
+
name = "tracing-test-exporter";
|
|
934
|
+
#events = [];
|
|
935
|
+
constructor(config = {}) {
|
|
936
|
+
super(config);
|
|
937
|
+
}
|
|
938
|
+
async _exportTracingEvent(event) {
|
|
939
|
+
this.#events.push(event);
|
|
940
|
+
}
|
|
941
|
+
clearEvents() {
|
|
942
|
+
this.#events = [];
|
|
943
|
+
}
|
|
944
|
+
get events() {
|
|
945
|
+
return this.#events;
|
|
946
|
+
}
|
|
947
|
+
async shutdown() {
|
|
948
|
+
this.logger.info("TestExporter shutdown");
|
|
949
|
+
}
|
|
950
|
+
};
|
|
898
951
|
var ModelSpanTracker = class {
|
|
899
952
|
#modelSpan;
|
|
900
953
|
#currentStepSpan;
|
|
@@ -1226,6 +1279,16 @@ function isSpanInternal(spanType, flags) {
|
|
|
1226
1279
|
return false;
|
|
1227
1280
|
}
|
|
1228
1281
|
}
|
|
1282
|
+
function getExternalParentId(options) {
|
|
1283
|
+
if (!options.parent) {
|
|
1284
|
+
return void 0;
|
|
1285
|
+
}
|
|
1286
|
+
if (options.parent.isInternal) {
|
|
1287
|
+
return options.parent.getParentSpanId(false);
|
|
1288
|
+
} else {
|
|
1289
|
+
return options.parent.id;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1229
1292
|
var BaseSpan = class {
|
|
1230
1293
|
name;
|
|
1231
1294
|
type;
|
|
@@ -1240,6 +1303,7 @@ var BaseSpan = class {
|
|
|
1240
1303
|
output;
|
|
1241
1304
|
errorInfo;
|
|
1242
1305
|
metadata;
|
|
1306
|
+
tags;
|
|
1243
1307
|
traceState;
|
|
1244
1308
|
/** Parent span ID (for root spans that are children of external spans) */
|
|
1245
1309
|
parentSpanId;
|
|
@@ -1254,6 +1318,7 @@ var BaseSpan = class {
|
|
|
1254
1318
|
this.isEvent = options.isEvent ?? false;
|
|
1255
1319
|
this.isInternal = isSpanInternal(this.type, options.tracingPolicy?.internal);
|
|
1256
1320
|
this.traceState = options.traceState;
|
|
1321
|
+
this.tags = !options.parent && options.tags?.length ? options.tags : void 0;
|
|
1257
1322
|
if (this.isEvent) {
|
|
1258
1323
|
this.output = deepClean(options.output);
|
|
1259
1324
|
} else {
|
|
@@ -1316,12 +1381,36 @@ var BaseSpan = class {
|
|
|
1316
1381
|
errorInfo: this.errorInfo,
|
|
1317
1382
|
isEvent: this.isEvent,
|
|
1318
1383
|
isRootSpan: this.isRootSpan,
|
|
1319
|
-
parentSpanId: this.getParentSpanId(includeInternalSpans)
|
|
1384
|
+
parentSpanId: this.getParentSpanId(includeInternalSpans),
|
|
1385
|
+
// Tags are only included for root spans
|
|
1386
|
+
...this.isRootSpan && this.tags?.length ? { tags: this.tags } : {}
|
|
1320
1387
|
};
|
|
1321
1388
|
}
|
|
1322
1389
|
get externalTraceId() {
|
|
1323
1390
|
return this.isValid ? this.traceId : void 0;
|
|
1324
1391
|
}
|
|
1392
|
+
/**
|
|
1393
|
+
* Execute an async function within this span's tracing context.
|
|
1394
|
+
* Delegates to the bridge if available.
|
|
1395
|
+
*/
|
|
1396
|
+
async executeInContext(fn) {
|
|
1397
|
+
const bridge = this.observabilityInstance.getBridge();
|
|
1398
|
+
if (bridge?.executeInContext) {
|
|
1399
|
+
return bridge.executeInContext(this.id, fn);
|
|
1400
|
+
}
|
|
1401
|
+
return fn();
|
|
1402
|
+
}
|
|
1403
|
+
/**
|
|
1404
|
+
* Execute a synchronous function within this span's tracing context.
|
|
1405
|
+
* Delegates to the bridge if available.
|
|
1406
|
+
*/
|
|
1407
|
+
executeInContextSync(fn) {
|
|
1408
|
+
const bridge = this.observabilityInstance.getBridge();
|
|
1409
|
+
if (bridge?.executeInContextSync) {
|
|
1410
|
+
return bridge.executeInContextSync(this.id, fn);
|
|
1411
|
+
}
|
|
1412
|
+
return fn();
|
|
1413
|
+
}
|
|
1325
1414
|
};
|
|
1326
1415
|
var DEFAULT_KEYS_TO_STRIP = /* @__PURE__ */ new Set([
|
|
1327
1416
|
"logger",
|
|
@@ -1368,27 +1457,30 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
1368
1457
|
traceId;
|
|
1369
1458
|
constructor(options, observabilityInstance) {
|
|
1370
1459
|
super(options, observabilityInstance);
|
|
1371
|
-
|
|
1460
|
+
const bridge = observabilityInstance.getBridge();
|
|
1461
|
+
if (bridge && !this.isInternal) {
|
|
1462
|
+
const bridgeIds = bridge.createSpan(options);
|
|
1463
|
+
if (bridgeIds) {
|
|
1464
|
+
this.id = bridgeIds.spanId;
|
|
1465
|
+
this.traceId = bridgeIds.traceId;
|
|
1466
|
+
this.parentSpanId = bridgeIds.parentSpanId;
|
|
1467
|
+
return;
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1372
1470
|
if (options.parent) {
|
|
1373
1471
|
this.traceId = options.parent.traceId;
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
} else {
|
|
1378
|
-
console.error(
|
|
1379
|
-
`[Mastra Tracing] Invalid traceId: must be 1-32 hexadecimal characters, got "${options.traceId}". Generating new trace ID.`
|
|
1380
|
-
);
|
|
1381
|
-
this.traceId = generateTraceId();
|
|
1382
|
-
}
|
|
1383
|
-
} else {
|
|
1384
|
-
this.traceId = generateTraceId();
|
|
1472
|
+
this.parentSpanId = options.parent.id;
|
|
1473
|
+
this.id = generateSpanId();
|
|
1474
|
+
return;
|
|
1385
1475
|
}
|
|
1386
|
-
|
|
1476
|
+
this.traceId = getOrCreateTraceId(options);
|
|
1477
|
+
this.id = generateSpanId();
|
|
1478
|
+
if (options.parentSpanId) {
|
|
1387
1479
|
if (isValidSpanId(options.parentSpanId)) {
|
|
1388
1480
|
this.parentSpanId = options.parentSpanId;
|
|
1389
1481
|
} else {
|
|
1390
1482
|
console.error(
|
|
1391
|
-
`[Mastra Tracing] Invalid parentSpanId: must be 1-16 hexadecimal characters, got "${options.parentSpanId}". Ignoring
|
|
1483
|
+
`[Mastra Tracing] Invalid parentSpanId: must be 1-16 hexadecimal characters, got "${options.parentSpanId}". Ignoring.`
|
|
1392
1484
|
);
|
|
1393
1485
|
}
|
|
1394
1486
|
}
|
|
@@ -1493,6 +1585,18 @@ function isValidTraceId(traceId) {
|
|
|
1493
1585
|
function isValidSpanId(spanId) {
|
|
1494
1586
|
return /^[0-9a-f]{1,16}$/i.test(spanId);
|
|
1495
1587
|
}
|
|
1588
|
+
function getOrCreateTraceId(options) {
|
|
1589
|
+
if (options.traceId) {
|
|
1590
|
+
if (isValidTraceId(options.traceId)) {
|
|
1591
|
+
return options.traceId;
|
|
1592
|
+
} else {
|
|
1593
|
+
console.error(
|
|
1594
|
+
`[Mastra Tracing] Invalid traceId: must be 1-32 hexadecimal characters, got "${options.traceId}". Generating new trace ID.`
|
|
1595
|
+
);
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
return generateTraceId();
|
|
1599
|
+
}
|
|
1496
1600
|
|
|
1497
1601
|
// src/spans/no-op.ts
|
|
1498
1602
|
var NoOpSpan = class extends BaseSpan {
|
|
@@ -1525,13 +1629,17 @@ var BaseObservabilityInstance = class extends base.MastraBase {
|
|
|
1525
1629
|
sampling: config.sampling ?? { type: "always" /* ALWAYS */ },
|
|
1526
1630
|
exporters: config.exporters ?? [],
|
|
1527
1631
|
spanOutputProcessors: config.spanOutputProcessors ?? [],
|
|
1632
|
+
bridge: config.bridge ?? void 0,
|
|
1528
1633
|
includeInternalSpans: config.includeInternalSpans ?? false,
|
|
1529
1634
|
requestContextKeys: config.requestContextKeys ?? []
|
|
1530
1635
|
};
|
|
1636
|
+
if (this.config.bridge?.init) {
|
|
1637
|
+
this.config.bridge.init({ config: this.config });
|
|
1638
|
+
}
|
|
1531
1639
|
}
|
|
1532
1640
|
/**
|
|
1533
1641
|
* Override setLogger to add Observability specific initialization log
|
|
1534
|
-
* and propagate logger to exporters
|
|
1642
|
+
* and propagate logger to exporters and bridge
|
|
1535
1643
|
*/
|
|
1536
1644
|
__setLogger(logger) {
|
|
1537
1645
|
super.__setLogger(logger);
|
|
@@ -1540,8 +1648,11 @@ var BaseObservabilityInstance = class extends base.MastraBase {
|
|
|
1540
1648
|
exporter.__setLogger(logger);
|
|
1541
1649
|
}
|
|
1542
1650
|
});
|
|
1651
|
+
if (this.config.bridge?.__setLogger) {
|
|
1652
|
+
this.config.bridge.__setLogger(logger);
|
|
1653
|
+
}
|
|
1543
1654
|
this.logger.debug(
|
|
1544
|
-
`[Observability] Initialized [service=${this.config.serviceName}] [instance=${this.config.name}] [sampling=${this.config.sampling
|
|
1655
|
+
`[Observability] Initialized [service=${this.config.serviceName}] [instance=${this.config.name}] [sampling=${this.config.sampling?.type}] [bridge=${!!this.config.bridge}]`
|
|
1545
1656
|
);
|
|
1546
1657
|
}
|
|
1547
1658
|
// ============================================================================
|
|
@@ -1570,11 +1681,15 @@ var BaseObservabilityInstance = class extends base.MastraBase {
|
|
|
1570
1681
|
} else {
|
|
1571
1682
|
traceState = this.computeTraceState(tracingOptions);
|
|
1572
1683
|
}
|
|
1573
|
-
const
|
|
1684
|
+
const tracingMetadata = !options.parent ? tracingOptions?.metadata : void 0;
|
|
1685
|
+
const mergedMetadata = metadata || tracingMetadata ? { ...metadata, ...tracingMetadata } : void 0;
|
|
1686
|
+
const enrichedMetadata = this.extractMetadataFromRequestContext(requestContext, mergedMetadata, traceState);
|
|
1687
|
+
const tags = !options.parent ? tracingOptions?.tags : void 0;
|
|
1574
1688
|
const span = this.createSpan({
|
|
1575
1689
|
...rest,
|
|
1576
1690
|
metadata: enrichedMetadata,
|
|
1577
|
-
traceState
|
|
1691
|
+
traceState,
|
|
1692
|
+
tags
|
|
1578
1693
|
});
|
|
1579
1694
|
if (span.isEvent) {
|
|
1580
1695
|
this.emitSpanEnded(span);
|
|
@@ -1608,6 +1723,12 @@ var BaseObservabilityInstance = class extends base.MastraBase {
|
|
|
1608
1723
|
getSpanOutputProcessors() {
|
|
1609
1724
|
return [...this.spanOutputProcessors];
|
|
1610
1725
|
}
|
|
1726
|
+
/**
|
|
1727
|
+
* Get the bridge instance if configured
|
|
1728
|
+
*/
|
|
1729
|
+
getBridge() {
|
|
1730
|
+
return this.config.bridge;
|
|
1731
|
+
}
|
|
1611
1732
|
/**
|
|
1612
1733
|
* Get the logger instance (for exporters and other components)
|
|
1613
1734
|
*/
|
|
@@ -1652,7 +1773,9 @@ var BaseObservabilityInstance = class extends base.MastraBase {
|
|
|
1652
1773
|
*/
|
|
1653
1774
|
shouldSample(options) {
|
|
1654
1775
|
const { sampling } = this.config;
|
|
1655
|
-
switch (sampling
|
|
1776
|
+
switch (sampling?.type) {
|
|
1777
|
+
case void 0:
|
|
1778
|
+
return true;
|
|
1656
1779
|
case "always" /* ALWAYS */:
|
|
1657
1780
|
return true;
|
|
1658
1781
|
case "never" /* NEVER */:
|
|
@@ -1784,17 +1907,21 @@ var BaseObservabilityInstance = class extends base.MastraBase {
|
|
|
1784
1907
|
}
|
|
1785
1908
|
}
|
|
1786
1909
|
/**
|
|
1787
|
-
* Export tracing event through all exporters (realtime mode)
|
|
1910
|
+
* Export tracing event through all exporters and bridge (realtime mode)
|
|
1788
1911
|
*/
|
|
1789
1912
|
async exportTracingEvent(event) {
|
|
1790
|
-
const
|
|
1913
|
+
const targets = [
|
|
1914
|
+
...this.exporters
|
|
1915
|
+
];
|
|
1916
|
+
if (this.config.bridge) {
|
|
1917
|
+
targets.push(this.config.bridge);
|
|
1918
|
+
}
|
|
1919
|
+
const exportPromises = targets.map(async (target) => {
|
|
1791
1920
|
try {
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
this.logger.debug(`[Observability] Event exported [exporter=${exporter.name}] [type=${event.type}]`);
|
|
1795
|
-
}
|
|
1921
|
+
await target.exportTracingEvent(event);
|
|
1922
|
+
this.logger.debug(`[Observability] Event exported [target=${target.name}] [type=${event.type}]`);
|
|
1796
1923
|
} catch (error) {
|
|
1797
|
-
this.logger.error(`[Observability] Export error [
|
|
1924
|
+
this.logger.error(`[Observability] Export error [target=${target.name}]`, error);
|
|
1798
1925
|
}
|
|
1799
1926
|
});
|
|
1800
1927
|
await Promise.allSettled(exportPromises);
|
|
@@ -1818,6 +1945,9 @@ var BaseObservabilityInstance = class extends base.MastraBase {
|
|
|
1818
1945
|
...this.exporters.map((e) => e.shutdown()),
|
|
1819
1946
|
...this.spanOutputProcessors.map((p) => p.shutdown())
|
|
1820
1947
|
];
|
|
1948
|
+
if (this.config.bridge) {
|
|
1949
|
+
shutdownPromises.push(this.config.bridge.shutdown());
|
|
1950
|
+
}
|
|
1821
1951
|
await Promise.allSettled(shutdownPromises);
|
|
1822
1952
|
this.logger.info(`[Observability] Shutdown completed [name=${this.name}]`);
|
|
1823
1953
|
}
|
|
@@ -1964,9 +2094,16 @@ var SensitiveDataFilter = class {
|
|
|
1964
2094
|
/**
|
|
1965
2095
|
* Recursively filter objects/arrays for sensitive keys.
|
|
1966
2096
|
* Handles circular references by replacing with a marker.
|
|
2097
|
+
* Also attempts to parse and redact JSON strings.
|
|
1967
2098
|
*/
|
|
1968
2099
|
deepFilter(obj, seen = /* @__PURE__ */ new WeakSet()) {
|
|
1969
2100
|
if (obj === null || typeof obj !== "object") {
|
|
2101
|
+
if (typeof obj === "string") {
|
|
2102
|
+
const trimmed = obj.trim();
|
|
2103
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
2104
|
+
return this.redactJsonString(obj);
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
1970
2107
|
return obj;
|
|
1971
2108
|
}
|
|
1972
2109
|
if (seen.has(obj)) {
|
|
@@ -2019,6 +2156,22 @@ var SensitiveDataFilter = class {
|
|
|
2019
2156
|
return normalizedKey === sensitiveField;
|
|
2020
2157
|
});
|
|
2021
2158
|
}
|
|
2159
|
+
/**
|
|
2160
|
+
* Attempt to parse a string as JSON and redact sensitive fields within it.
|
|
2161
|
+
* If parsing fails or no sensitive data is found, returns the original string.
|
|
2162
|
+
*/
|
|
2163
|
+
redactJsonString(str) {
|
|
2164
|
+
try {
|
|
2165
|
+
const parsed = JSON.parse(str);
|
|
2166
|
+
if (parsed && typeof parsed === "object") {
|
|
2167
|
+
const filtered = this.deepFilter(parsed, /* @__PURE__ */ new WeakSet());
|
|
2168
|
+
return JSON.stringify(filtered);
|
|
2169
|
+
}
|
|
2170
|
+
return str;
|
|
2171
|
+
} catch {
|
|
2172
|
+
return str;
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2022
2175
|
/**
|
|
2023
2176
|
* Redact a sensitive value.
|
|
2024
2177
|
* - Full style: replaces with a fixed token.
|
|
@@ -2184,7 +2337,9 @@ exports.NoOpSpan = NoOpSpan;
|
|
|
2184
2337
|
exports.Observability = Observability;
|
|
2185
2338
|
exports.SamplingStrategyType = SamplingStrategyType;
|
|
2186
2339
|
exports.SensitiveDataFilter = SensitiveDataFilter;
|
|
2340
|
+
exports.TestExporter = TestExporter;
|
|
2187
2341
|
exports.deepClean = deepClean;
|
|
2342
|
+
exports.getExternalParentId = getExternalParentId;
|
|
2188
2343
|
exports.observabilityConfigValueSchema = observabilityConfigValueSchema;
|
|
2189
2344
|
exports.observabilityInstanceConfigSchema = observabilityInstanceConfigSchema;
|
|
2190
2345
|
exports.observabilityRegistryConfigSchema = observabilityRegistryConfigSchema;
|