@mastra/observability 1.7.3 → 1.8.0-alpha.0
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 +42 -0
- package/dist/bus/observability-bus.d.ts +6 -2
- package/dist/bus/observability-bus.d.ts.map +1 -1
- package/dist/exporters/cloud.d.ts +23 -2
- package/dist/exporters/cloud.d.ts.map +1 -1
- package/dist/index.cjs +757 -345
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +756 -346
- package/dist/index.js.map +1 -1
- package/dist/instances/base.d.ts.map +1 -1
- package/dist/spans/serialization.d.ts +8 -0
- package/dist/spans/serialization.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @mastra/observability
|
|
2
2
|
|
|
3
|
+
## 1.8.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added CloudExporter support for Mastra Observability logs, metrics, scores, and feedback. ([#15124](https://github.com/mastra-ai/mastra/pull/15124))
|
|
8
|
+
|
|
9
|
+
CloudExporter now batches and uploads all Mastra Observability signals to Mastra Cloud, not just tracing spans.
|
|
10
|
+
|
|
11
|
+
This includes a breaking change to the CloudExporter endpoint format. We now pass a base endpoint URL and let let the exporter derive the standard publish paths automatically.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { CloudExporter, Observability } from '@mastra/observability';
|
|
15
|
+
|
|
16
|
+
const observability = new Observability({
|
|
17
|
+
configs: {
|
|
18
|
+
default: {
|
|
19
|
+
serviceName: 'my-app',
|
|
20
|
+
exporters: [
|
|
21
|
+
new CloudExporter({
|
|
22
|
+
endpoint: 'https://collector.example.com',
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Traces, logs, metrics, scores, and feedback now all publish through CloudExporter.
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
After updating the exporter endpoint config, the exporter will continue to work for traces, and the same exporter will now also publish structured logs, auto-extracted metrics, scores, and feedback records.
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- ObservabilityBus now honors per-instance `serializationOptions` (maxStringLength, maxDepth, maxArrayLength, maxObjectKeys) when deep-cleaning log/metric/score/feedback payloads, matching the behavior of tracing spans. Previously these signals always used the built-in defaults regardless of user configuration. ([#15138](https://github.com/mastra-ai/mastra/pull/15138))
|
|
37
|
+
|
|
38
|
+
- Apply `deepClean()` to all observability signals (logs, metrics, scores, feedback) before fanning out to exporters and bridges. Previously only tracing spans were deep-cleaned at construction time, leaving free-form payload fields on other signals (e.g. `log.data`, `log.metadata`, `metric.metadata`, `metric.costContext.costMetadata`, `score.metadata`, `feedback.metadata`) susceptible to circular references, oversized strings, and other non-serializable values. Sanitization now happens centrally in `ObservabilityBus.emit()` so every signal leaving the bus is bounded and JSON-safe. ([#15135](https://github.com/mastra-ai/mastra/pull/15135))
|
|
39
|
+
|
|
40
|
+
- `deepClean()` now preserves data for `Map`, `Set`, and richer `Error` objects. Previously Maps and Sets were serialized as empty `{}` (entries silently dropped) and Errors only kept `name`/`message`. Maps are now converted to plain objects of entries, Sets to arrays (both respecting `maxObjectKeys`/`maxArrayLength` and cycle detection), and Errors additionally preserve `stack` and recursively cleaned `cause`. ([#15136](https://github.com/mastra-ai/mastra/pull/15136))
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [[`153e864`](https://github.com/mastra-ai/mastra/commit/153e86476b425db7cd0dc8490050096e92964a38)]:
|
|
43
|
+
- @mastra/core@1.23.1-alpha.0
|
|
44
|
+
|
|
3
45
|
## 1.7.3
|
|
4
46
|
|
|
5
47
|
### Patch Changes
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Handler presence = signal support. If a handler does not implement a method,
|
|
10
10
|
* events of that type are silently skipped for that handler.
|
|
11
11
|
*/
|
|
12
|
-
import type { ObservabilityExporter, ObservabilityBridge, ObservabilityEvent } from '@mastra/core/observability';
|
|
12
|
+
import type { ObservabilityExporter, ObservabilityBridge, ObservabilityEvent, SerializationOptions } from '@mastra/core/observability';
|
|
13
13
|
import { BaseObservabilityEventBus } from './base.js';
|
|
14
14
|
/**
|
|
15
15
|
* Unified event bus for all observability signals (tracing, logs, metrics, scores, feedback).
|
|
@@ -20,7 +20,11 @@ export declare class ObservabilityBus extends BaseObservabilityEventBus<Observab
|
|
|
20
20
|
private bridge?;
|
|
21
21
|
/** In-flight handler promises from routeToHandler. Self-cleaning via .finally(). */
|
|
22
22
|
private pendingHandlers;
|
|
23
|
-
|
|
23
|
+
/** Resolved deepClean options applied to non-tracing events before fan-out. */
|
|
24
|
+
private deepCleanOptions;
|
|
25
|
+
constructor(opts?: {
|
|
26
|
+
serializationOptions?: SerializationOptions;
|
|
27
|
+
});
|
|
24
28
|
/**
|
|
25
29
|
* Register an exporter to receive routed events.
|
|
26
30
|
* Duplicate registrations (same instance) are silently ignored.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observability-bus.d.ts","sourceRoot":"","sources":["../../src/bus/observability-bus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"observability-bus.d.ts","sourceRoot":"","sources":["../../src/bus/observability-bus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,QAAQ,CAAC;AAsCnD;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,yBAAyB,CAAC,kBAAkB,CAAC;IACjF,OAAO,CAAC,SAAS,CAA+B;IAChD,OAAO,CAAC,MAAM,CAAC,CAAsB;IAErC,oFAAoF;IACpF,OAAO,CAAC,eAAe,CAAiC;IAExD,+EAA+E;IAC/E,OAAO,CAAC,gBAAgB,CAAmB;gBAE/B,IAAI,CAAC,EAAE;QAAE,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;KAAE;IAKlE;;;;;OAKG;IACH,gBAAgB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI;IAOvD;;;;;OAKG;IACH,kBAAkB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,OAAO;IAS5D;;OAEG;IACH,YAAY,IAAI,SAAS,qBAAqB,EAAE;IAIhD;;;;;;OAMG;IACH,cAAc,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI;IAOjD;;;;OAIG;IACH,gBAAgB,IAAI,OAAO;IAQ3B;;OAEG;IACH,SAAS,IAAI,mBAAmB,GAAG,SAAS;IAI5C;;;;;;OAMG;IACH,IAAI,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI;IAoBrC;;;OAGG;IACH,OAAO,CAAC,YAAY;IAQpB;;;;;;;;;;;OAWG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA+B5B,6EAA6E;IACvE,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAIhC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TracingEvent } from '@mastra/core/observability';
|
|
1
|
+
import type { TracingEvent, LogEvent, MetricEvent, ScoreEvent, FeedbackEvent } from '@mastra/core/observability';
|
|
2
2
|
import { BaseExporter } from './base.js';
|
|
3
3
|
import type { BaseExporterConfig } from './base.js';
|
|
4
4
|
export interface CloudExporterConfig extends BaseExporterConfig {
|
|
@@ -7,23 +7,44 @@ export interface CloudExporterConfig extends BaseExporterConfig {
|
|
|
7
7
|
maxRetries?: number;
|
|
8
8
|
accessToken?: string;
|
|
9
9
|
endpoint?: string;
|
|
10
|
+
tracesEndpoint?: string;
|
|
11
|
+
logsEndpoint?: string;
|
|
12
|
+
metricsEndpoint?: string;
|
|
13
|
+
scoresEndpoint?: string;
|
|
14
|
+
feedbackEndpoint?: string;
|
|
10
15
|
}
|
|
11
16
|
export declare class CloudExporter extends BaseExporter {
|
|
12
17
|
name: string;
|
|
13
18
|
private cloudConfig;
|
|
14
19
|
private buffer;
|
|
15
20
|
private flushTimer;
|
|
21
|
+
private inFlightFlushes;
|
|
16
22
|
constructor(config?: CloudExporterConfig);
|
|
17
23
|
protected _exportTracingEvent(event: TracingEvent): Promise<void>;
|
|
24
|
+
onLogEvent(event: LogEvent): Promise<void>;
|
|
25
|
+
onMetricEvent(event: MetricEvent): Promise<void>;
|
|
26
|
+
onScoreEvent(event: ScoreEvent): Promise<void>;
|
|
27
|
+
onFeedbackEvent(event: FeedbackEvent): Promise<void>;
|
|
18
28
|
private addToBuffer;
|
|
29
|
+
private addLogToBuffer;
|
|
30
|
+
private addMetricToBuffer;
|
|
31
|
+
private addScoreToBuffer;
|
|
32
|
+
private addFeedbackToBuffer;
|
|
33
|
+
private markBufferStart;
|
|
19
34
|
private formatSpan;
|
|
35
|
+
private formatLog;
|
|
36
|
+
private formatMetric;
|
|
37
|
+
private formatScore;
|
|
38
|
+
private formatFeedback;
|
|
39
|
+
private handleBufferedEvent;
|
|
20
40
|
private shouldFlush;
|
|
21
41
|
private scheduleFlush;
|
|
22
42
|
private flushBuffer;
|
|
23
43
|
/**
|
|
24
|
-
* Uploads
|
|
44
|
+
* Uploads a signal batch to the configured cloud API using fetchWithRetry.
|
|
25
45
|
*/
|
|
26
46
|
private batchUpload;
|
|
47
|
+
private flushSignalBatch;
|
|
27
48
|
private resetBuffer;
|
|
28
49
|
/**
|
|
29
50
|
* Force flush any buffered spans without shutting down the exporter.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud.d.ts","sourceRoot":"","sources":["../../src/exporters/cloud.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"cloud.d.ts","sourceRoot":"","sources":["../../src/exporters/cloud.ts"],"names":[],"mappings":"AAGA,OAAO,K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