@mastra/observability 1.24.0-alpha.6 → 1.24.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.
@@ -3,7 +3,7 @@ name: mastra-observability
3
3
  description: Documentation for @mastra/observability. Use when working with @mastra/observability APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/observability"
6
- version: "1.24.0-alpha.6"
6
+ version: "1.24.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,11 +1,11 @@
1
1
  {
2
- "version": "1.24.0-alpha.6",
2
+ "version": "1.24.0",
3
3
  "package": "@mastra/observability",
4
4
  "exports": {
5
5
  "BaseExporter": {
6
6
  "types": "dist/exporters/base.d.ts",
7
7
  "implementation": "dist/index.js",
8
- "line": 4294
8
+ "line": 4314
9
9
  },
10
10
  "BaseObservabilityEventBus": {
11
11
  "types": "dist/bus/base.d.ts",
@@ -15,7 +15,7 @@
15
15
  "BaseObservabilityInstance": {
16
16
  "types": "dist/instances/base.d.ts",
17
17
  "implementation": "dist/index.js",
18
- "line": 6232
18
+ "line": 6252
19
19
  },
20
20
  "BaseSpan": {
21
21
  "types": "dist/spans/base.d.ts",
@@ -30,12 +30,12 @@
30
30
  "CloudExporter": {
31
31
  "types": "dist/exporters/cloud.d.ts",
32
32
  "implementation": "dist/index.js",
33
- "line": 8652
33
+ "line": 8675
34
34
  },
35
35
  "ConsoleExporter": {
36
36
  "types": "dist/exporters/console.d.ts",
37
37
  "implementation": "dist/index.js",
38
- "line": 8975
38
+ "line": 8998
39
39
  },
40
40
  "DEFAULT_DEEP_CLEAN_OPTIONS": {
41
41
  "types": "dist/spans/serialization.d.ts",
@@ -45,27 +45,27 @@
45
45
  "DEFAULT_LIMITS": {
46
46
  "types": "dist/client/proxy.d.ts",
47
47
  "implementation": "dist/index.js",
48
- "line": 7218
48
+ "line": 7241
49
49
  },
50
50
  "DefaultExporter": {
51
51
  "types": "dist/exporters/default.d.ts",
52
52
  "implementation": "dist/index.js",
53
- "line": 5054
53
+ "line": 5074
54
54
  },
55
55
  "DefaultObservabilityInstance": {
56
56
  "types": "dist/instances/default.d.ts",
57
57
  "implementation": "dist/index.js",
58
- "line": 10903
58
+ "line": 10926
59
59
  },
60
60
  "DefaultSpan": {
61
61
  "types": "dist/spans/default.d.ts",
62
62
  "implementation": "dist/index.js",
63
- "line": 4063
63
+ "line": 4082
64
64
  },
65
65
  "JsonExporter": {
66
66
  "types": "dist/exporters/test.d.ts",
67
67
  "implementation": "dist/index.js",
68
- "line": 10901
68
+ "line": 10924
69
69
  },
70
70
  "LoggerContextImpl": {
71
71
  "types": "dist/context/logger.d.ts",
@@ -75,12 +75,12 @@
75
75
  "MastraPlatformExporter": {
76
76
  "types": "dist/exporters/mastra-platform.d.ts",
77
77
  "implementation": "dist/index.js",
78
- "line": 9305
78
+ "line": 9328
79
79
  },
80
80
  "MastraStorageExporter": {
81
81
  "types": "dist/exporters/mastra-storage.d.ts",
82
82
  "implementation": "dist/index.js",
83
- "line": 5615
83
+ "line": 5635
84
84
  },
85
85
  "MetricsContextImpl": {
86
86
  "types": "dist/context/metrics.d.ts",
@@ -95,17 +95,17 @@
95
95
  "NoOpSpan": {
96
96
  "types": "dist/spans/no-op.d.ts",
97
97
  "implementation": "dist/index.js",
98
- "line": 4237
98
+ "line": 4257
99
99
  },
100
100
  "OBSERVABILITY_CAPABILITIES_HEADER": {
101
101
  "types": "dist/exporters/mastra-platform.d.ts",
102
102
  "implementation": "dist/index.js",
103
- "line": 9206
103
+ "line": 9229
104
104
  },
105
105
  "Observability": {
106
106
  "types": "dist/default.d.ts",
107
107
  "implementation": "dist/index.js",
108
- "line": 11239
108
+ "line": 11262
109
109
  },
110
110
  "ObservabilityBus": {
111
111
  "types": "dist/bus/observability-bus.d.ts",
@@ -115,7 +115,7 @@
115
115
  "QUOTA_PAUSE_CAPABILITY": {
116
116
  "types": "dist/exporters/mastra-platform.d.ts",
117
117
  "implementation": "dist/index.js",
118
- "line": 9207
118
+ "line": 9230
119
119
  },
120
120
  "REDACTED_ERROR_MESSAGE": {
121
121
  "types": "dist/spans/base.d.ts",
@@ -130,57 +130,57 @@
130
130
  "SensitiveDataFilter": {
131
131
  "types": "dist/span_processors/sensitive-data-filter.d.ts",
132
132
  "implementation": "dist/index.js",
133
- "line": 11026
133
+ "line": 11049
134
134
  },
135
135
  "TestExporter": {
136
136
  "types": "dist/exporters/test.d.ts",
137
137
  "implementation": "dist/index.js",
138
- "line": 9916
138
+ "line": 9939
139
139
  },
140
140
  "TraceData": {
141
141
  "types": "dist/exporters/tracking.d.ts",
142
142
  "implementation": "dist/index.js",
143
- "line": 7371
143
+ "line": 7394
144
144
  },
145
145
  "TrackingExporter": {
146
146
  "types": "dist/exporters/tracking.d.ts",
147
147
  "implementation": "dist/index.js",
148
- "line": 7700
148
+ "line": 7723
149
149
  },
150
150
  "buildExportedLog": {
151
151
  "types": "dist/client/otlp.d.ts",
152
152
  "implementation": "dist/index.js",
153
- "line": 7135
153
+ "line": 7158
154
154
  },
155
155
  "buildExportedSpan": {
156
156
  "types": "dist/client/otlp.d.ts",
157
157
  "implementation": "dist/index.js",
158
- "line": 7117
158
+ "line": 7140
159
159
  },
160
160
  "buildTracingOptions": {
161
161
  "types": "dist/tracing-options.d.ts",
162
162
  "implementation": "dist/index.js",
163
- "line": 11580
163
+ "line": 11603
164
164
  },
165
165
  "chainFormatters": {
166
166
  "types": "dist/exporters/span-formatters.d.ts",
167
167
  "implementation": "dist/index.js",
168
- "line": 8466
168
+ "line": 8489
169
169
  },
170
170
  "createClientObservabilityProxy": {
171
171
  "types": "dist/client/proxy.d.ts",
172
172
  "implementation": "dist/index.js",
173
- "line": 7352
173
+ "line": 7375
174
174
  },
175
175
  "decodeResourceLogs": {
176
176
  "types": "dist/client/otlp.d.ts",
177
177
  "implementation": "dist/index.js",
178
- "line": 7054
178
+ "line": 7077
179
179
  },
180
180
  "decodeResourceSpans": {
181
181
  "types": "dist/client/otlp.d.ts",
182
182
  "implementation": "dist/index.js",
183
- "line": 7017
183
+ "line": 7040
184
184
  },
185
185
  "deepClean": {
186
186
  "types": "dist/spans/serialization.d.ts",
@@ -190,12 +190,12 @@
190
190
  "formatBaggage": {
191
191
  "types": "dist/client/w3c.d.ts",
192
192
  "implementation": "dist/index.js",
193
- "line": 7208
193
+ "line": 7231
194
194
  },
195
195
  "formatTraceparent": {
196
196
  "types": "dist/client/w3c.d.ts",
197
197
  "implementation": "dist/index.js",
198
- "line": 7171
198
+ "line": 7194
199
199
  },
200
200
  "getExternalParentId": {
201
201
  "types": "dist/spans/base.d.ts",
@@ -220,7 +220,7 @@
220
220
  "observabilityFeatures": {
221
221
  "types": "dist/features.d.ts",
222
222
  "implementation": "dist/index.js",
223
- "line": 11561
223
+ "line": 11584
224
224
  },
225
225
  "observabilityInstanceConfigSchema": {
226
226
  "types": "dist/config.d.ts",
@@ -235,17 +235,17 @@
235
235
  "otlpSeverityToLogLevel": {
236
236
  "types": "dist/client/otlp.d.ts",
237
237
  "implementation": "dist/index.js",
238
- "line": 7091
238
+ "line": 7114
239
239
  },
240
240
  "parseBaggage": {
241
241
  "types": "dist/client/w3c.d.ts",
242
242
  "implementation": "dist/index.js",
243
- "line": 7181
243
+ "line": 7204
244
244
  },
245
245
  "parseTraceparent": {
246
246
  "types": "dist/client/w3c.d.ts",
247
247
  "implementation": "dist/index.js",
248
- "line": 7157
248
+ "line": 7180
249
249
  },
250
250
  "reconstructSerializedMap": {
251
251
  "types": "dist/spans/serialization.d.ts",
package/dist/index.cjs CHANGED
@@ -3621,6 +3621,23 @@ var BaseSpan = class BaseSpan {
3621
3621
  tags;
3622
3622
  links;
3623
3623
  traceState;
3624
+ localErrorCount = typeof _mastra_core_observability.claimSpanError === "function" ? 0 : void 0;
3625
+ errorOccurrenceIds;
3626
+ recordError(error, options) {
3627
+ if (this.isEvent || this.endTime) return;
3628
+ if (error === null || typeof error !== "object" && typeof error !== "function") {
3629
+ this.localErrorCount = void 0;
3630
+ return;
3631
+ }
3632
+ const id = _mastra_core_observability.claimSpanError?.(error, this.traceId, this.id, options);
3633
+ if (this.isExcluded || id === void 0 || this.errorOccurrenceIds?.has(id)) return;
3634
+ (this.errorOccurrenceIds ??= /* @__PURE__ */ new Set()).add(id);
3635
+ if (this.localErrorCount !== void 0) this.localErrorCount++;
3636
+ }
3637
+ restoreErrorCount(cached) {
3638
+ this.localErrorCount = typeof _mastra_core_observability.claimSpanError !== "function" || cached.errorCount && !cached.errorOccurrenceIds ? void 0 : cached.errorCount;
3639
+ this.errorOccurrenceIds = cached.errorOccurrenceIds?.length ? new Set(cached.errorOccurrenceIds) : void 0;
3640
+ }
3624
3641
  /** Entity type that created the span (e.g., agent, workflow) */
3625
3642
  entityType;
3626
3643
  /** Entity ID that created the span */
@@ -4004,6 +4021,7 @@ var BaseSpan = class BaseSpan {
4004
4021
  input: hideInput ? void 0 : this.input,
4005
4022
  output: hideOutput ? void 0 : this.output,
4006
4023
  errorInfo: hideInput || hideOutput ? redactErrorInfo(this.errorInfo, this.errorStackMessage) : this.errorInfo,
4024
+ ...this.localErrorCount !== void 0 ? { errorCount: this.localErrorCount } : {},
4007
4025
  ...this.outcome !== void 0 ? { outcome: this.outcome } : {},
4008
4026
  ...this.stopReason !== void 0 ? { stopReason: this.stopReason } : {},
4009
4027
  ...this.stopReasonContext !== void 0 ? { stopReasonContext: this.stopReasonContext } : {},
@@ -4029,6 +4047,7 @@ var BaseSpan = class BaseSpan {
4029
4047
  return {
4030
4048
  ...this.exportSpan(this.observabilityInstance.getConfig().includeInternalSpans),
4031
4049
  ownEntityVersionId: this.ownEntityVersionId ?? null,
4050
+ ...this.errorOccurrenceIds ? { errorOccurrenceIds: [...this.errorOccurrenceIds] } : {},
4032
4051
  ...this.traceState ? { traceState: this.traceState } : {}
4033
4052
  };
4034
4053
  }
@@ -4148,6 +4167,7 @@ var DefaultSpan = class extends BaseSpan {
4148
4167
  error(options) {
4149
4168
  if (this.isEvent || this.endTime) return;
4150
4169
  const { error, endSpan = true, endTree, attributes, metadata } = options;
4170
+ this.recordError(error, { origin: options.origin });
4151
4171
  this.applyOutcome(options);
4152
4172
  if (metadata) this.metadata = {
4153
4173
  ...this.metadata,
@@ -6436,7 +6456,10 @@ var BaseObservabilityInstance = class extends _mastra_core_base.MastraBase {
6436
6456
  tracingPolicy: cached.isInternal ? { internal: _mastra_core_observability.InternalSpans.ALL } : void 0,
6437
6457
  traceState: this.rebuildTraceState(cached)
6438
6458
  });
6439
- if (span instanceof BaseSpan) span.restoreEntityLineage(cached);
6459
+ if (span instanceof BaseSpan) {
6460
+ span.restoreEntityLineage(cached);
6461
+ span.restoreErrorCount(cached);
6462
+ }
6440
6463
  if (cached.endTime) {
6441
6464
  span.endTime = cached.endTime instanceof Date ? cached.endTime : new Date(cached.endTime);
6442
6465
  span.output = cached.output;