@mastra/observability 1.16.3 → 1.16.4-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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @mastra/observability
2
2
 
3
+ ## 1.16.4-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed logs and metrics emitted outside of a span (for example server request logs) being stored without an environment or service name. They now inherit the Mastra-level environment (from the environment config option or NODE_ENV) and the configured service name, so filtering by environment in Studio Observability no longer hides these logs and metrics. Relates to https://github.com/mastra-ai/mastra/issues/19870 ([#19892](https://github.com/mastra-ai/mastra/pull/19892))
8
+
9
+ - Updated dependencies [[`322daa6`](https://github.com/mastra-ai/mastra/commit/322daa6d90552909204044790d850958f6745fed), [`cadaa13`](https://github.com/mastra-ai/mastra/commit/cadaa1372e1077c8e85eb64c5499ba8803caa323), [`06000d7`](https://github.com/mastra-ai/mastra/commit/06000d73712911572e913b8a83339270296d0a22), [`3de0188`](https://github.com/mastra-ai/mastra/commit/3de0188bfaf9a9c09c95fe322b53838cf52c70b6)]:
10
+ - @mastra/core@1.56.0-alpha.2
11
+
3
12
  ## 1.16.3
4
13
 
5
14
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -3108,13 +3108,24 @@ var BaseObservabilityInstance = class extends _mastra_core_base.MastraBase {
3108
3108
  return this.observabilityBus;
3109
3109
  }
3110
3110
  /**
3111
+ * Minimal correlation context for span-less logger and metrics contexts,
3112
+ * so their signals still carry the Mastra-level environment and serviceName
3113
+ * instead of persisting null.
3114
+ */
3115
+ buildFallbackCorrelationContext() {
3116
+ return {
3117
+ environment: this.#mastraEnvironment,
3118
+ serviceName: this.config.serviceName
3119
+ };
3120
+ }
3121
+ /**
3111
3122
  * Get a LoggerContext correlated to a span.
3112
3123
  * Called by the context-factory in core (deriveLoggerContext) so that
3113
3124
  * `observabilityContext.loggerVNext` is a real logger instead of no-op.
3114
3125
  */
3115
3126
  getLoggerContext(span) {
3116
3127
  if (this.config.logging?.enabled === false) return _mastra_core_observability.noOpLoggerContext;
3117
- const correlationContext = span?.getCorrelationContext?.();
3128
+ const correlationContext = span?.getCorrelationContext?.() ?? this.buildFallbackCorrelationContext();
3118
3129
  const metadata = span?.metadata ? structuredClone(span.metadata) : void 0;
3119
3130
  return new LoggerContextImpl({
3120
3131
  traceId: span?.traceId,
@@ -3131,7 +3142,7 @@ var BaseObservabilityInstance = class extends _mastra_core_base.MastraBase {
3131
3142
  * `observabilityContext.metrics` is a real metrics context instead of no-op.
3132
3143
  */
3133
3144
  getMetricsContext(span) {
3134
- const correlationContext = span?.getCorrelationContext?.();
3145
+ const correlationContext = span?.getCorrelationContext?.() ?? this.buildFallbackCorrelationContext();
3135
3146
  const metadata = span?.metadata ? structuredClone(span.metadata) : void 0;
3136
3147
  return new MetricsContextImpl({
3137
3148
  traceId: span?.traceId,