@mastra/observability 1.6.0 → 1.7.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 +32 -0
- package/dist/config.d.ts +11 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/index.cjs +22 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -3
- package/dist/index.js.map +1 -1
- package/dist/instances/base.d.ts +5 -0
- package/dist/instances/base.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MastraBase } from '@mastra/core/base';
|
|
2
2
|
import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
|
|
3
3
|
import { ConsoleLogger, LogLevel, RegisteredLogger } from '@mastra/core/logger';
|
|
4
|
-
import { TracingEventType, DEFAULT_BLOCKED_LABELS, SpanType, InternalSpans } from '@mastra/core/observability';
|
|
4
|
+
import { TracingEventType, DEFAULT_BLOCKED_LABELS, SpanType, noOpLoggerContext, InternalSpans } from '@mastra/core/observability';
|
|
5
5
|
import { fetchWithRetry, getNestedValue, setNestedValue } from '@mastra/core/utils';
|
|
6
6
|
import { buildUpdateSpanRecord, buildFeedbackRecord, buildLogRecord, buildMetricRecord, buildScoreRecord, buildCreateSpanRecord } from '@mastra/core/storage';
|
|
7
7
|
import fs from 'fs';
|
|
@@ -19021,7 +19021,8 @@ var BaseObservabilityInstance = class extends MastraBase {
|
|
|
19021
19021
|
bridge: config2.bridge ?? void 0,
|
|
19022
19022
|
includeInternalSpans: config2.includeInternalSpans ?? false,
|
|
19023
19023
|
requestContextKeys: config2.requestContextKeys ?? [],
|
|
19024
|
-
serializationOptions: config2.serializationOptions
|
|
19024
|
+
serializationOptions: config2.serializationOptions,
|
|
19025
|
+
logging: config2.logging
|
|
19025
19026
|
};
|
|
19026
19027
|
this.cardinalityFilter = new CardinalityFilter(config2.cardinality);
|
|
19027
19028
|
this.observabilityBus = new ObservabilityBus();
|
|
@@ -19166,6 +19167,21 @@ var BaseObservabilityInstance = class extends MastraBase {
|
|
|
19166
19167
|
getExporters() {
|
|
19167
19168
|
return [...this.exporters];
|
|
19168
19169
|
}
|
|
19170
|
+
/**
|
|
19171
|
+
* Register an additional exporter at runtime.
|
|
19172
|
+
* Adds to both the bus (for event routing) and the config (for getExporters).
|
|
19173
|
+
*/
|
|
19174
|
+
registerExporter(exporter) {
|
|
19175
|
+
this.observabilityBus.registerExporter(exporter);
|
|
19176
|
+
this.config.exporters ??= [];
|
|
19177
|
+
if (this.config.exporters.includes(exporter)) {
|
|
19178
|
+
return;
|
|
19179
|
+
}
|
|
19180
|
+
this.config.exporters.push(exporter);
|
|
19181
|
+
if (typeof exporter.__setLogger === "function") {
|
|
19182
|
+
exporter.__setLogger(this.logger);
|
|
19183
|
+
}
|
|
19184
|
+
}
|
|
19169
19185
|
/**
|
|
19170
19186
|
* Get all span output processors
|
|
19171
19187
|
*/
|
|
@@ -19201,6 +19217,9 @@ var BaseObservabilityInstance = class extends MastraBase {
|
|
|
19201
19217
|
* `observabilityContext.loggerVNext` is a real logger instead of no-op.
|
|
19202
19218
|
*/
|
|
19203
19219
|
getLoggerContext(span) {
|
|
19220
|
+
if (this.config.logging?.enabled === false) {
|
|
19221
|
+
return noOpLoggerContext;
|
|
19222
|
+
}
|
|
19204
19223
|
const correlationContext = span?.getCorrelationContext?.();
|
|
19205
19224
|
const metadata = span?.metadata ? structuredClone(span.metadata) : void 0;
|
|
19206
19225
|
return new LoggerContextImpl({
|
|
@@ -19208,7 +19227,8 @@ var BaseObservabilityInstance = class extends MastraBase {
|
|
|
19208
19227
|
spanId: span?.id,
|
|
19209
19228
|
correlationContext,
|
|
19210
19229
|
metadata,
|
|
19211
|
-
observabilityBus: this.observabilityBus
|
|
19230
|
+
observabilityBus: this.observabilityBus,
|
|
19231
|
+
minLevel: this.config.logging?.level
|
|
19212
19232
|
});
|
|
19213
19233
|
}
|
|
19214
19234
|
/**
|