@mastra/observability 0.0.0-sidebar-window-undefined-fix-20251029233656 → 0.0.0-testing-cloud-studios-20260114234039

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +626 -3
  2. package/README.md +54 -0
  3. package/dist/config.d.ts +553 -0
  4. package/dist/config.d.ts.map +1 -0
  5. package/dist/default.d.ts +29 -0
  6. package/dist/default.d.ts.map +1 -0
  7. package/dist/exporters/base.d.ts +111 -0
  8. package/dist/exporters/base.d.ts.map +1 -0
  9. package/dist/exporters/cloud.d.ts +30 -0
  10. package/dist/exporters/cloud.d.ts.map +1 -0
  11. package/dist/exporters/console.d.ts +10 -0
  12. package/dist/exporters/console.d.ts.map +1 -0
  13. package/dist/exporters/default.d.ts +90 -0
  14. package/dist/exporters/default.d.ts.map +1 -0
  15. package/dist/exporters/index.d.ts +10 -0
  16. package/dist/exporters/index.d.ts.map +1 -0
  17. package/dist/exporters/test.d.ts +13 -0
  18. package/dist/exporters/test.d.ts.map +1 -0
  19. package/dist/index.cjs +6742 -0
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.ts +9 -2
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +6716 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/instances/base.d.ts +119 -0
  26. package/dist/instances/base.d.ts.map +1 -0
  27. package/dist/instances/default.d.ts +8 -0
  28. package/dist/instances/default.d.ts.map +1 -0
  29. package/dist/instances/index.d.ts +6 -0
  30. package/dist/instances/index.d.ts.map +1 -0
  31. package/dist/model-tracing.d.ts +55 -0
  32. package/dist/model-tracing.d.ts.map +1 -0
  33. package/dist/registry.d.ts +49 -0
  34. package/dist/registry.d.ts.map +1 -0
  35. package/dist/span_processors/index.d.ts +5 -0
  36. package/dist/span_processors/index.d.ts.map +1 -0
  37. package/dist/span_processors/sensitive-data-filter.d.ts +92 -0
  38. package/dist/span_processors/sensitive-data-filter.d.ts.map +1 -0
  39. package/dist/spans/base.d.ts +102 -0
  40. package/dist/spans/base.d.ts.map +1 -0
  41. package/dist/spans/default.d.ts +13 -0
  42. package/dist/spans/default.d.ts.map +1 -0
  43. package/dist/spans/index.d.ts +8 -0
  44. package/dist/spans/index.d.ts.map +1 -0
  45. package/dist/spans/no-op.d.ts +15 -0
  46. package/dist/spans/no-op.d.ts.map +1 -0
  47. package/dist/spans/serialization.d.ts +46 -0
  48. package/dist/spans/serialization.d.ts.map +1 -0
  49. package/dist/tracing-options.d.ts +27 -0
  50. package/dist/tracing-options.d.ts.map +1 -0
  51. package/dist/usage.d.ts +21 -0
  52. package/dist/usage.d.ts.map +1 -0
  53. package/package.json +17 -11
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # Mastra Observability
2
+
3
+ Tracing and monitoring for AI operations in Mastra.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @mastra/observability
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { Mastra } from '@mastra/core';
15
+ import { Observability, DefaultExporter, CloudExporter, SensitiveDataFilter } from '@mastra/observability';
16
+
17
+ export const mastra = new Mastra({
18
+ observability: new Observability({
19
+ configs: {
20
+ default: {
21
+ serviceName: 'my-app',
22
+ exporters: [
23
+ new DefaultExporter(), // Persists traces for Mastra Studio
24
+ new CloudExporter(), // Sends to Mastra Cloud
25
+ ],
26
+ spanOutputProcessors: [new SensitiveDataFilter()],
27
+ },
28
+ },
29
+ }),
30
+ });
31
+ ```
32
+
33
+ ## Features
34
+
35
+ - **Auto-instrumentation** - Traces agent runs, LLM calls, tool executions, and workflows
36
+ - **Pluggable Exporters** - Exporters for Studio and Cloud, plus integrations for Arize, Braintrust, Langfuse, LangSmith, and OpenTelemetry
37
+ - **Sampling Strategies** - Always, ratio-based, or custom sampling
38
+ - **Span Processors** - Transform or filter span data before export
39
+ - **OpenTelemetry Compatible** - Standard trace/span ID formats for integration
40
+
41
+ ## Span Types
42
+
43
+ - `WORKFLOW_RUN` - Workflow execution
44
+ - `WORKFLOW_STEP` - Individual workflow step
45
+ - `AGENT_RUN` - Agent processing
46
+ - `MODEL_GENERATION` - LLM API calls
47
+ - `TOOL_CALL` - Tool execution
48
+ - `MCP_TOOL_CALL` - MCP tool execution
49
+ - `PROCESSOR_RUN` - Processor execution
50
+ - `GENERIC` - Custom operations
51
+
52
+ ## Documentation
53
+
54
+ For configuration options, exporters, sampling strategies, and more, see the [full documentation](https://mastra.ai/docs/v1/observability/overview).
@@ -0,0 +1,553 @@
1
+ /**
2
+ * Configuration types for Mastra Observability
3
+ *
4
+ * These types define the configuration structure for observability,
5
+ * including tracing configs, sampling strategies, and registry setup.
6
+ */
7
+ import type { RequestContext } from '@mastra/core/di';
8
+ import type { ObservabilityInstance, ObservabilityExporter, ObservabilityBridge, SpanOutputProcessor, ConfigSelector, SerializationOptions } from '@mastra/core/observability';
9
+ import { z } from 'zod';
10
+ /**
11
+ * Sampling strategy types
12
+ */
13
+ export declare enum SamplingStrategyType {
14
+ ALWAYS = "always",
15
+ NEVER = "never",
16
+ RATIO = "ratio",
17
+ CUSTOM = "custom"
18
+ }
19
+ /**
20
+ * Options passed when using a custom sampler strategy
21
+ */
22
+ export interface CustomSamplerOptions {
23
+ requestContext?: RequestContext;
24
+ metadata?: Record<string, any>;
25
+ }
26
+ /**
27
+ * Sampling strategy configuration
28
+ */
29
+ export type SamplingStrategy = {
30
+ type: SamplingStrategyType.ALWAYS;
31
+ } | {
32
+ type: SamplingStrategyType.NEVER;
33
+ } | {
34
+ type: SamplingStrategyType.RATIO;
35
+ probability: number;
36
+ } | {
37
+ type: SamplingStrategyType.CUSTOM;
38
+ sampler: (options?: CustomSamplerOptions) => boolean;
39
+ };
40
+ /**
41
+ * Configuration for a single observability instance
42
+ */
43
+ export interface ObservabilityInstanceConfig {
44
+ /** Unique identifier for this config in the tracing registry */
45
+ name: string;
46
+ /** Service name for tracing */
47
+ serviceName: string;
48
+ /** Sampling strategy - controls whether tracing is collected (defaults to ALWAYS) */
49
+ sampling?: SamplingStrategy;
50
+ /** Custom exporters */
51
+ exporters?: ObservabilityExporter[];
52
+ /** Observability bridge (e.g., OpenTelemetry bridge for context extraction) */
53
+ bridge?: ObservabilityBridge;
54
+ /** Custom span output processors */
55
+ spanOutputProcessors?: SpanOutputProcessor[];
56
+ /** Set to `true` if you want to see spans internal to the operation of mastra */
57
+ includeInternalSpans?: boolean;
58
+ /**
59
+ * RequestContext keys to automatically extract as metadata for all spans
60
+ * created with this tracing configuration.
61
+ * Supports dot notation for nested values.
62
+ */
63
+ requestContextKeys?: string[];
64
+ /**
65
+ * Options for controlling serialization of span data (input/output/attributes).
66
+ * Use these to customize truncation limits for large payloads.
67
+ */
68
+ serializationOptions?: SerializationOptions;
69
+ }
70
+ /**
71
+ * Complete Observability registry configuration
72
+ */
73
+ export interface ObservabilityRegistryConfig {
74
+ /**
75
+ * Enables default exporters, with sampling: always, and sensitive data filtering
76
+ * @deprecated Use explicit `configs` with DefaultExporter, CloudExporter, and SensitiveDataFilter instead.
77
+ * This option will be removed in a future version.
78
+ */
79
+ default?: {
80
+ enabled?: boolean;
81
+ };
82
+ /** Map of tracing instance names to their configurations or pre-instantiated instances */
83
+ configs?: Record<string, Omit<ObservabilityInstanceConfig, 'name'> | ObservabilityInstance>;
84
+ /** Optional selector function to choose which tracing instance to use */
85
+ configSelector?: ConfigSelector;
86
+ }
87
+ /**
88
+ * Zod schema for SamplingStrategy
89
+ */
90
+ export declare const samplingStrategySchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
91
+ type: z.ZodLiteral<SamplingStrategyType.ALWAYS>;
92
+ }, "strip", z.ZodTypeAny, {
93
+ type: SamplingStrategyType.ALWAYS;
94
+ }, {
95
+ type: SamplingStrategyType.ALWAYS;
96
+ }>, z.ZodObject<{
97
+ type: z.ZodLiteral<SamplingStrategyType.NEVER>;
98
+ }, "strip", z.ZodTypeAny, {
99
+ type: SamplingStrategyType.NEVER;
100
+ }, {
101
+ type: SamplingStrategyType.NEVER;
102
+ }>, z.ZodObject<{
103
+ type: z.ZodLiteral<SamplingStrategyType.RATIO>;
104
+ probability: z.ZodNumber;
105
+ }, "strip", z.ZodTypeAny, {
106
+ type: SamplingStrategyType.RATIO;
107
+ probability: number;
108
+ }, {
109
+ type: SamplingStrategyType.RATIO;
110
+ probability: number;
111
+ }>, z.ZodObject<{
112
+ type: z.ZodLiteral<SamplingStrategyType.CUSTOM>;
113
+ sampler: z.ZodFunction<z.ZodTuple<[z.ZodOptional<z.ZodAny>], z.ZodUnknown>, z.ZodBoolean>;
114
+ }, "strip", z.ZodTypeAny, {
115
+ type: SamplingStrategyType.CUSTOM;
116
+ sampler: (args_0: any, ...args: unknown[]) => boolean;
117
+ }, {
118
+ type: SamplingStrategyType.CUSTOM;
119
+ sampler: (args_0: any, ...args: unknown[]) => boolean;
120
+ }>]>;
121
+ /**
122
+ * Zod schema for SerializationOptions
123
+ */
124
+ export declare const serializationOptionsSchema: z.ZodOptional<z.ZodObject<{
125
+ maxStringLength: z.ZodOptional<z.ZodNumber>;
126
+ maxDepth: z.ZodOptional<z.ZodNumber>;
127
+ maxArrayLength: z.ZodOptional<z.ZodNumber>;
128
+ maxObjectKeys: z.ZodOptional<z.ZodNumber>;
129
+ }, "strip", z.ZodTypeAny, {
130
+ maxStringLength?: number | undefined;
131
+ maxDepth?: number | undefined;
132
+ maxArrayLength?: number | undefined;
133
+ maxObjectKeys?: number | undefined;
134
+ }, {
135
+ maxStringLength?: number | undefined;
136
+ maxDepth?: number | undefined;
137
+ maxArrayLength?: number | undefined;
138
+ maxObjectKeys?: number | undefined;
139
+ }>>;
140
+ /**
141
+ * Zod schema for ObservabilityInstanceConfig
142
+ * Note: exporters, spanOutputProcessors, bridge, and configSelector are validated as any
143
+ * since they're complex runtime objects
144
+ */
145
+ export declare const observabilityInstanceConfigSchema: z.ZodEffects<z.ZodObject<{
146
+ name: z.ZodString;
147
+ serviceName: z.ZodString;
148
+ sampling: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
149
+ type: z.ZodLiteral<SamplingStrategyType.ALWAYS>;
150
+ }, "strip", z.ZodTypeAny, {
151
+ type: SamplingStrategyType.ALWAYS;
152
+ }, {
153
+ type: SamplingStrategyType.ALWAYS;
154
+ }>, z.ZodObject<{
155
+ type: z.ZodLiteral<SamplingStrategyType.NEVER>;
156
+ }, "strip", z.ZodTypeAny, {
157
+ type: SamplingStrategyType.NEVER;
158
+ }, {
159
+ type: SamplingStrategyType.NEVER;
160
+ }>, z.ZodObject<{
161
+ type: z.ZodLiteral<SamplingStrategyType.RATIO>;
162
+ probability: z.ZodNumber;
163
+ }, "strip", z.ZodTypeAny, {
164
+ type: SamplingStrategyType.RATIO;
165
+ probability: number;
166
+ }, {
167
+ type: SamplingStrategyType.RATIO;
168
+ probability: number;
169
+ }>, z.ZodObject<{
170
+ type: z.ZodLiteral<SamplingStrategyType.CUSTOM>;
171
+ sampler: z.ZodFunction<z.ZodTuple<[z.ZodOptional<z.ZodAny>], z.ZodUnknown>, z.ZodBoolean>;
172
+ }, "strip", z.ZodTypeAny, {
173
+ type: SamplingStrategyType.CUSTOM;
174
+ sampler: (args_0: any, ...args: unknown[]) => boolean;
175
+ }, {
176
+ type: SamplingStrategyType.CUSTOM;
177
+ sampler: (args_0: any, ...args: unknown[]) => boolean;
178
+ }>]>>;
179
+ exporters: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
180
+ bridge: z.ZodOptional<z.ZodAny>;
181
+ spanOutputProcessors: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
182
+ includeInternalSpans: z.ZodOptional<z.ZodBoolean>;
183
+ requestContextKeys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
184
+ serializationOptions: z.ZodOptional<z.ZodObject<{
185
+ maxStringLength: z.ZodOptional<z.ZodNumber>;
186
+ maxDepth: z.ZodOptional<z.ZodNumber>;
187
+ maxArrayLength: z.ZodOptional<z.ZodNumber>;
188
+ maxObjectKeys: z.ZodOptional<z.ZodNumber>;
189
+ }, "strip", z.ZodTypeAny, {
190
+ maxStringLength?: number | undefined;
191
+ maxDepth?: number | undefined;
192
+ maxArrayLength?: number | undefined;
193
+ maxObjectKeys?: number | undefined;
194
+ }, {
195
+ maxStringLength?: number | undefined;
196
+ maxDepth?: number | undefined;
197
+ maxArrayLength?: number | undefined;
198
+ maxObjectKeys?: number | undefined;
199
+ }>>;
200
+ }, "strip", z.ZodTypeAny, {
201
+ name: string;
202
+ serviceName: string;
203
+ sampling?: {
204
+ type: SamplingStrategyType.ALWAYS;
205
+ } | {
206
+ type: SamplingStrategyType.NEVER;
207
+ } | {
208
+ type: SamplingStrategyType.RATIO;
209
+ probability: number;
210
+ } | {
211
+ type: SamplingStrategyType.CUSTOM;
212
+ sampler: (args_0: any, ...args: unknown[]) => boolean;
213
+ } | undefined;
214
+ exporters?: any[] | undefined;
215
+ bridge?: any;
216
+ spanOutputProcessors?: any[] | undefined;
217
+ includeInternalSpans?: boolean | undefined;
218
+ requestContextKeys?: string[] | undefined;
219
+ serializationOptions?: {
220
+ maxStringLength?: number | undefined;
221
+ maxDepth?: number | undefined;
222
+ maxArrayLength?: number | undefined;
223
+ maxObjectKeys?: number | undefined;
224
+ } | undefined;
225
+ }, {
226
+ name: string;
227
+ serviceName: string;
228
+ sampling?: {
229
+ type: SamplingStrategyType.ALWAYS;
230
+ } | {
231
+ type: SamplingStrategyType.NEVER;
232
+ } | {
233
+ type: SamplingStrategyType.RATIO;
234
+ probability: number;
235
+ } | {
236
+ type: SamplingStrategyType.CUSTOM;
237
+ sampler: (args_0: any, ...args: unknown[]) => boolean;
238
+ } | undefined;
239
+ exporters?: any[] | undefined;
240
+ bridge?: any;
241
+ spanOutputProcessors?: any[] | undefined;
242
+ includeInternalSpans?: boolean | undefined;
243
+ requestContextKeys?: string[] | undefined;
244
+ serializationOptions?: {
245
+ maxStringLength?: number | undefined;
246
+ maxDepth?: number | undefined;
247
+ maxArrayLength?: number | undefined;
248
+ maxObjectKeys?: number | undefined;
249
+ } | undefined;
250
+ }>, {
251
+ name: string;
252
+ serviceName: string;
253
+ sampling?: {
254
+ type: SamplingStrategyType.ALWAYS;
255
+ } | {
256
+ type: SamplingStrategyType.NEVER;
257
+ } | {
258
+ type: SamplingStrategyType.RATIO;
259
+ probability: number;
260
+ } | {
261
+ type: SamplingStrategyType.CUSTOM;
262
+ sampler: (args_0: any, ...args: unknown[]) => boolean;
263
+ } | undefined;
264
+ exporters?: any[] | undefined;
265
+ bridge?: any;
266
+ spanOutputProcessors?: any[] | undefined;
267
+ includeInternalSpans?: boolean | undefined;
268
+ requestContextKeys?: string[] | undefined;
269
+ serializationOptions?: {
270
+ maxStringLength?: number | undefined;
271
+ maxDepth?: number | undefined;
272
+ maxArrayLength?: number | undefined;
273
+ maxObjectKeys?: number | undefined;
274
+ } | undefined;
275
+ }, {
276
+ name: string;
277
+ serviceName: string;
278
+ sampling?: {
279
+ type: SamplingStrategyType.ALWAYS;
280
+ } | {
281
+ type: SamplingStrategyType.NEVER;
282
+ } | {
283
+ type: SamplingStrategyType.RATIO;
284
+ probability: number;
285
+ } | {
286
+ type: SamplingStrategyType.CUSTOM;
287
+ sampler: (args_0: any, ...args: unknown[]) => boolean;
288
+ } | undefined;
289
+ exporters?: any[] | undefined;
290
+ bridge?: any;
291
+ spanOutputProcessors?: any[] | undefined;
292
+ includeInternalSpans?: boolean | undefined;
293
+ requestContextKeys?: string[] | undefined;
294
+ serializationOptions?: {
295
+ maxStringLength?: number | undefined;
296
+ maxDepth?: number | undefined;
297
+ maxArrayLength?: number | undefined;
298
+ maxObjectKeys?: number | undefined;
299
+ } | undefined;
300
+ }>;
301
+ /**
302
+ * Zod schema for config values in the configs map
303
+ * This is the config object without the name field
304
+ */
305
+ export declare const observabilityConfigValueSchema: z.ZodEffects<z.ZodObject<{
306
+ serviceName: z.ZodString;
307
+ sampling: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
308
+ type: z.ZodLiteral<SamplingStrategyType.ALWAYS>;
309
+ }, "strip", z.ZodTypeAny, {
310
+ type: SamplingStrategyType.ALWAYS;
311
+ }, {
312
+ type: SamplingStrategyType.ALWAYS;
313
+ }>, z.ZodObject<{
314
+ type: z.ZodLiteral<SamplingStrategyType.NEVER>;
315
+ }, "strip", z.ZodTypeAny, {
316
+ type: SamplingStrategyType.NEVER;
317
+ }, {
318
+ type: SamplingStrategyType.NEVER;
319
+ }>, z.ZodObject<{
320
+ type: z.ZodLiteral<SamplingStrategyType.RATIO>;
321
+ probability: z.ZodNumber;
322
+ }, "strip", z.ZodTypeAny, {
323
+ type: SamplingStrategyType.RATIO;
324
+ probability: number;
325
+ }, {
326
+ type: SamplingStrategyType.RATIO;
327
+ probability: number;
328
+ }>, z.ZodObject<{
329
+ type: z.ZodLiteral<SamplingStrategyType.CUSTOM>;
330
+ sampler: z.ZodFunction<z.ZodTuple<[z.ZodOptional<z.ZodAny>], z.ZodUnknown>, z.ZodBoolean>;
331
+ }, "strip", z.ZodTypeAny, {
332
+ type: SamplingStrategyType.CUSTOM;
333
+ sampler: (args_0: any, ...args: unknown[]) => boolean;
334
+ }, {
335
+ type: SamplingStrategyType.CUSTOM;
336
+ sampler: (args_0: any, ...args: unknown[]) => boolean;
337
+ }>]>>;
338
+ exporters: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
339
+ bridge: z.ZodOptional<z.ZodAny>;
340
+ spanOutputProcessors: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
341
+ includeInternalSpans: z.ZodOptional<z.ZodBoolean>;
342
+ requestContextKeys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
343
+ serializationOptions: z.ZodOptional<z.ZodObject<{
344
+ maxStringLength: z.ZodOptional<z.ZodNumber>;
345
+ maxDepth: z.ZodOptional<z.ZodNumber>;
346
+ maxArrayLength: z.ZodOptional<z.ZodNumber>;
347
+ maxObjectKeys: z.ZodOptional<z.ZodNumber>;
348
+ }, "strip", z.ZodTypeAny, {
349
+ maxStringLength?: number | undefined;
350
+ maxDepth?: number | undefined;
351
+ maxArrayLength?: number | undefined;
352
+ maxObjectKeys?: number | undefined;
353
+ }, {
354
+ maxStringLength?: number | undefined;
355
+ maxDepth?: number | undefined;
356
+ maxArrayLength?: number | undefined;
357
+ maxObjectKeys?: number | undefined;
358
+ }>>;
359
+ }, "strip", z.ZodTypeAny, {
360
+ serviceName: string;
361
+ sampling?: {
362
+ type: SamplingStrategyType.ALWAYS;
363
+ } | {
364
+ type: SamplingStrategyType.NEVER;
365
+ } | {
366
+ type: SamplingStrategyType.RATIO;
367
+ probability: number;
368
+ } | {
369
+ type: SamplingStrategyType.CUSTOM;
370
+ sampler: (args_0: any, ...args: unknown[]) => boolean;
371
+ } | undefined;
372
+ exporters?: any[] | undefined;
373
+ bridge?: any;
374
+ spanOutputProcessors?: any[] | undefined;
375
+ includeInternalSpans?: boolean | undefined;
376
+ requestContextKeys?: string[] | undefined;
377
+ serializationOptions?: {
378
+ maxStringLength?: number | undefined;
379
+ maxDepth?: number | undefined;
380
+ maxArrayLength?: number | undefined;
381
+ maxObjectKeys?: number | undefined;
382
+ } | undefined;
383
+ }, {
384
+ serviceName: string;
385
+ sampling?: {
386
+ type: SamplingStrategyType.ALWAYS;
387
+ } | {
388
+ type: SamplingStrategyType.NEVER;
389
+ } | {
390
+ type: SamplingStrategyType.RATIO;
391
+ probability: number;
392
+ } | {
393
+ type: SamplingStrategyType.CUSTOM;
394
+ sampler: (args_0: any, ...args: unknown[]) => boolean;
395
+ } | undefined;
396
+ exporters?: any[] | undefined;
397
+ bridge?: any;
398
+ spanOutputProcessors?: any[] | undefined;
399
+ includeInternalSpans?: boolean | undefined;
400
+ requestContextKeys?: string[] | undefined;
401
+ serializationOptions?: {
402
+ maxStringLength?: number | undefined;
403
+ maxDepth?: number | undefined;
404
+ maxArrayLength?: number | undefined;
405
+ maxObjectKeys?: number | undefined;
406
+ } | undefined;
407
+ }>, {
408
+ serviceName: string;
409
+ sampling?: {
410
+ type: SamplingStrategyType.ALWAYS;
411
+ } | {
412
+ type: SamplingStrategyType.NEVER;
413
+ } | {
414
+ type: SamplingStrategyType.RATIO;
415
+ probability: number;
416
+ } | {
417
+ type: SamplingStrategyType.CUSTOM;
418
+ sampler: (args_0: any, ...args: unknown[]) => boolean;
419
+ } | undefined;
420
+ exporters?: any[] | undefined;
421
+ bridge?: any;
422
+ spanOutputProcessors?: any[] | undefined;
423
+ includeInternalSpans?: boolean | undefined;
424
+ requestContextKeys?: string[] | undefined;
425
+ serializationOptions?: {
426
+ maxStringLength?: number | undefined;
427
+ maxDepth?: number | undefined;
428
+ maxArrayLength?: number | undefined;
429
+ maxObjectKeys?: number | undefined;
430
+ } | undefined;
431
+ }, {
432
+ serviceName: string;
433
+ sampling?: {
434
+ type: SamplingStrategyType.ALWAYS;
435
+ } | {
436
+ type: SamplingStrategyType.NEVER;
437
+ } | {
438
+ type: SamplingStrategyType.RATIO;
439
+ probability: number;
440
+ } | {
441
+ type: SamplingStrategyType.CUSTOM;
442
+ sampler: (args_0: any, ...args: unknown[]) => boolean;
443
+ } | undefined;
444
+ exporters?: any[] | undefined;
445
+ bridge?: any;
446
+ spanOutputProcessors?: any[] | undefined;
447
+ includeInternalSpans?: boolean | undefined;
448
+ requestContextKeys?: string[] | undefined;
449
+ serializationOptions?: {
450
+ maxStringLength?: number | undefined;
451
+ maxDepth?: number | undefined;
452
+ maxArrayLength?: number | undefined;
453
+ maxObjectKeys?: number | undefined;
454
+ } | undefined;
455
+ }>;
456
+ /**
457
+ * Zod schema for ObservabilityRegistryConfig
458
+ * Note: Individual configs are validated separately in the constructor to allow for
459
+ * both plain config objects and pre-instantiated ObservabilityInstance objects.
460
+ * The schema is permissive to handle edge cases gracefully (arrays, null values).
461
+ */
462
+ export declare const observabilityRegistryConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
463
+ default: z.ZodNullable<z.ZodOptional<z.ZodObject<{
464
+ enabled: z.ZodOptional<z.ZodBoolean>;
465
+ }, "strip", z.ZodTypeAny, {
466
+ enabled?: boolean | undefined;
467
+ }, {
468
+ enabled?: boolean | undefined;
469
+ }>>>;
470
+ configs: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny, "many">, z.ZodNull]>>;
471
+ configSelector: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
472
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
473
+ default: z.ZodNullable<z.ZodOptional<z.ZodObject<{
474
+ enabled: z.ZodOptional<z.ZodBoolean>;
475
+ }, "strip", z.ZodTypeAny, {
476
+ enabled?: boolean | undefined;
477
+ }, {
478
+ enabled?: boolean | undefined;
479
+ }>>>;
480
+ configs: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny, "many">, z.ZodNull]>>;
481
+ configSelector: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
482
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
483
+ default: z.ZodNullable<z.ZodOptional<z.ZodObject<{
484
+ enabled: z.ZodOptional<z.ZodBoolean>;
485
+ }, "strip", z.ZodTypeAny, {
486
+ enabled?: boolean | undefined;
487
+ }, {
488
+ enabled?: boolean | undefined;
489
+ }>>>;
490
+ configs: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny, "many">, z.ZodNull]>>;
491
+ configSelector: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
492
+ }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
493
+ default: z.ZodNullable<z.ZodOptional<z.ZodObject<{
494
+ enabled: z.ZodOptional<z.ZodBoolean>;
495
+ }, "strip", z.ZodTypeAny, {
496
+ enabled?: boolean | undefined;
497
+ }, {
498
+ enabled?: boolean | undefined;
499
+ }>>>;
500
+ configs: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny, "many">, z.ZodNull]>>;
501
+ configSelector: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
502
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
503
+ default: z.ZodNullable<z.ZodOptional<z.ZodObject<{
504
+ enabled: z.ZodOptional<z.ZodBoolean>;
505
+ }, "strip", z.ZodTypeAny, {
506
+ enabled?: boolean | undefined;
507
+ }, {
508
+ enabled?: boolean | undefined;
509
+ }>>>;
510
+ configs: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny, "many">, z.ZodNull]>>;
511
+ configSelector: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
512
+ }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
513
+ default: z.ZodNullable<z.ZodOptional<z.ZodObject<{
514
+ enabled: z.ZodOptional<z.ZodBoolean>;
515
+ }, "strip", z.ZodTypeAny, {
516
+ enabled?: boolean | undefined;
517
+ }, {
518
+ enabled?: boolean | undefined;
519
+ }>>>;
520
+ configs: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny, "many">, z.ZodNull]>>;
521
+ configSelector: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
522
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
523
+ default: z.ZodNullable<z.ZodOptional<z.ZodObject<{
524
+ enabled: z.ZodOptional<z.ZodBoolean>;
525
+ }, "strip", z.ZodTypeAny, {
526
+ enabled?: boolean | undefined;
527
+ }, {
528
+ enabled?: boolean | undefined;
529
+ }>>>;
530
+ configs: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny, "many">, z.ZodNull]>>;
531
+ configSelector: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
532
+ }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
533
+ default: z.ZodNullable<z.ZodOptional<z.ZodObject<{
534
+ enabled: z.ZodOptional<z.ZodBoolean>;
535
+ }, "strip", z.ZodTypeAny, {
536
+ enabled?: boolean | undefined;
537
+ }, {
538
+ enabled?: boolean | undefined;
539
+ }>>>;
540
+ configs: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny, "many">, z.ZodNull]>>;
541
+ configSelector: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
542
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
543
+ default: z.ZodNullable<z.ZodOptional<z.ZodObject<{
544
+ enabled: z.ZodOptional<z.ZodBoolean>;
545
+ }, "strip", z.ZodTypeAny, {
546
+ enabled?: boolean | undefined;
547
+ }, {
548
+ enabled?: boolean | undefined;
549
+ }>>>;
550
+ configs: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny, "many">, z.ZodNull]>>;
551
+ configSelector: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
552
+ }, z.ZodTypeAny, "passthrough">>;
553
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,29 @@
1
+ import type { Mastra } from '@mastra/core';
2
+ import { MastraBase } from '@mastra/core/base';
3
+ import type { IMastraLogger } from '@mastra/core/logger';
4
+ import type { ConfigSelector, ConfigSelectorOptions, ObservabilityEntrypoint, ObservabilityInstance } from '@mastra/core/observability';
5
+ import type { ObservabilityRegistryConfig } from './config.js';
6
+ export declare class Observability extends MastraBase implements ObservabilityEntrypoint {
7
+ #private;
8
+ constructor(config: ObservabilityRegistryConfig);
9
+ setMastraContext(options: {
10
+ mastra: Mastra;
11
+ }): void;
12
+ setLogger(options: {
13
+ logger: IMastraLogger;
14
+ }): void;
15
+ getSelectedInstance(options: ConfigSelectorOptions): ObservabilityInstance | undefined;
16
+ /**
17
+ * Registry management methods
18
+ */
19
+ registerInstance(name: string, instance: ObservabilityInstance, isDefault?: boolean): void;
20
+ getInstance(name: string): ObservabilityInstance | undefined;
21
+ getDefaultInstance(): ObservabilityInstance | undefined;
22
+ listInstances(): ReadonlyMap<string, ObservabilityInstance>;
23
+ unregisterInstance(name: string): boolean;
24
+ hasInstance(name: string): boolean;
25
+ setConfigSelector(selector: ConfigSelector): void;
26
+ clear(): void;
27
+ shutdown(): Promise<void>;
28
+ }
29
+ //# sourceMappingURL=default.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../src/default.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAA+B,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAezF,qBAAa,aAAc,SAAQ,UAAW,YAAW,uBAAuB;;gBAGlE,MAAM,EAAE,2BAA2B;IA4F/C,gBAAgB,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAuBnD,SAAS,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,aAAa,CAAA;KAAE,GAAG,IAAI;IAOnD,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,GAAG,qBAAqB,GAAG,SAAS;IAItF;;OAEG;IAEH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,qBAAqB,EAAE,SAAS,UAAQ,GAAG,IAAI;IAIxF,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS;IAI5D,kBAAkB,IAAI,qBAAqB,GAAG,SAAS;IAIvD,aAAa,IAAI,WAAW,CAAC,MAAM,EAAE,qBAAqB,CAAC;IAI3D,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIzC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIlC,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAIjD,KAAK,IAAI,IAAI;IAIP,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC"}