@mastra/observability 1.16.3 → 1.16.4-alpha.1
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 +24 -0
- package/dist/index.cjs +27 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -2
- package/dist/index.js.map +1 -1
- package/dist/instances/base.d.ts +10 -0
- package/dist/instances/base.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -3083,13 +3083,24 @@ var BaseObservabilityInstance = class extends MastraBase {
|
|
|
3083
3083
|
return this.observabilityBus;
|
|
3084
3084
|
}
|
|
3085
3085
|
/**
|
|
3086
|
+
* Minimal correlation context for span-less logger and metrics contexts,
|
|
3087
|
+
* so their signals still carry the Mastra-level environment and serviceName
|
|
3088
|
+
* instead of persisting null.
|
|
3089
|
+
*/
|
|
3090
|
+
buildFallbackCorrelationContext() {
|
|
3091
|
+
return {
|
|
3092
|
+
environment: this.#mastraEnvironment,
|
|
3093
|
+
serviceName: this.config.serviceName
|
|
3094
|
+
};
|
|
3095
|
+
}
|
|
3096
|
+
/**
|
|
3086
3097
|
* Get a LoggerContext correlated to a span.
|
|
3087
3098
|
* Called by the context-factory in core (deriveLoggerContext) so that
|
|
3088
3099
|
* `observabilityContext.loggerVNext` is a real logger instead of no-op.
|
|
3089
3100
|
*/
|
|
3090
3101
|
getLoggerContext(span) {
|
|
3091
3102
|
if (this.config.logging?.enabled === false) return noOpLoggerContext;
|
|
3092
|
-
const correlationContext = span?.getCorrelationContext?.();
|
|
3103
|
+
const correlationContext = span?.getCorrelationContext?.() ?? this.buildFallbackCorrelationContext();
|
|
3093
3104
|
const metadata = span?.metadata ? structuredClone(span.metadata) : void 0;
|
|
3094
3105
|
return new LoggerContextImpl({
|
|
3095
3106
|
traceId: span?.traceId,
|
|
@@ -3106,7 +3117,7 @@ var BaseObservabilityInstance = class extends MastraBase {
|
|
|
3106
3117
|
* `observabilityContext.metrics` is a real metrics context instead of no-op.
|
|
3107
3118
|
*/
|
|
3108
3119
|
getMetricsContext(span) {
|
|
3109
|
-
const correlationContext = span?.getCorrelationContext?.();
|
|
3120
|
+
const correlationContext = span?.getCorrelationContext?.() ?? this.buildFallbackCorrelationContext();
|
|
3110
3121
|
const metadata = span?.metadata ? structuredClone(span.metadata) : void 0;
|
|
3111
3122
|
return new MetricsContextImpl({
|
|
3112
3123
|
traceId: span?.traceId,
|
|
@@ -3317,6 +3328,20 @@ var BaseObservabilityInstance = class extends MastraBase {
|
|
|
3317
3328
|
exportedSpan
|
|
3318
3329
|
};
|
|
3319
3330
|
this.emitTracingEvent(event);
|
|
3331
|
+
return;
|
|
3332
|
+
}
|
|
3333
|
+
this.releaseBridgeSpan(span);
|
|
3334
|
+
}
|
|
3335
|
+
/**
|
|
3336
|
+
* Release bridge state for a span that ended without being exported.
|
|
3337
|
+
*/
|
|
3338
|
+
releaseBridgeSpan(span) {
|
|
3339
|
+
const bridge = this.getBridge();
|
|
3340
|
+
if (!bridge?.releaseSpan) return;
|
|
3341
|
+
try {
|
|
3342
|
+
bridge.releaseSpan(span.id, span.traceId);
|
|
3343
|
+
} catch (error) {
|
|
3344
|
+
this.logger.error(`[Observability] Bridge releaseSpan error [spanId=${span.id}]`, error);
|
|
3320
3345
|
}
|
|
3321
3346
|
}
|
|
3322
3347
|
/**
|