@mastra/observability 1.24.3-alpha.0 → 1.24.3
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/dist/docs/SKILL.md +5 -4
- package/dist/docs/assets/SOURCE_MAP.json +39 -39
- package/dist/docs/references/docs-mastra-platform-observability-overview.md +1 -1
- package/dist/docs/references/docs-observability-feedback.md +1 -1
- package/dist/docs/references/docs-observability-metrics-overview.md +57 -2
- package/dist/docs/references/integrations-observability-sentry.md +53 -12
- package/dist/docs/references/reference-observability-metrics-metrics-context.md +117 -0
- package/dist/docs/references/reference-observability-tracing-bridges-datadog.md +12 -0
- package/dist/docs/references/reference-observability-tracing-configuration.md +7 -0
- package/dist/docs/references/reference-observability-tracing-exporters-datadog.md +50 -0
- package/dist/index.cjs +3409 -2384
- package/dist/index.js +3409 -2384
- package/package.json +8 -7
- package/dist/bus/base.d.ts.map +0 -1
- package/dist/bus/index.d.ts.map +0 -1
- package/dist/bus/observability-bus.d.ts.map +0 -1
- package/dist/bus/route-event.d.ts.map +0 -1
- package/dist/client/id.d.ts.map +0 -1
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/otlp.d.ts.map +0 -1
- package/dist/client/proxy.d.ts.map +0 -1
- package/dist/client/w3c.d.ts.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/logger.d.ts.map +0 -1
- package/dist/context/metrics.d.ts.map +0 -1
- package/dist/default.d.ts.map +0 -1
- package/dist/exporters/auth-failure-cooldown.d.ts.map +0 -1
- package/dist/exporters/base.d.ts.map +0 -1
- package/dist/exporters/cloud.d.ts.map +0 -1
- package/dist/exporters/console.d.ts.map +0 -1
- package/dist/exporters/default.d.ts.map +0 -1
- package/dist/exporters/event-buffer.d.ts.map +0 -1
- package/dist/exporters/index.d.ts.map +0 -1
- package/dist/exporters/keyed-queue.d.ts.map +0 -1
- package/dist/exporters/mastra-platform.d.ts.map +0 -1
- package/dist/exporters/mastra-storage.d.ts.map +0 -1
- package/dist/exporters/platform-byte-batcher.d.ts.map +0 -1
- package/dist/exporters/platform-resolved-record.d.ts.map +0 -1
- package/dist/exporters/span-formatters.d.ts.map +0 -1
- package/dist/exporters/span-previews.d.ts.map +0 -1
- package/dist/exporters/storage-annotation.d.ts.map +0 -1
- package/dist/exporters/storage-byte-tracker.d.ts.map +0 -1
- package/dist/exporters/storage-platform-policy.d.ts.map +0 -1
- package/dist/exporters/test.d.ts.map +0 -1
- package/dist/exporters/tracking.d.ts.map +0 -1
- package/dist/features.d.ts.map +0 -1
- package/dist/ids.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/instances/base.d.ts.map +0 -1
- package/dist/instances/default.d.ts.map +0 -1
- package/dist/instances/index.d.ts.map +0 -1
- package/dist/instances/platform-policy.d.ts.map +0 -1
- package/dist/metrics/auto-extract.d.ts.map +0 -1
- package/dist/metrics/cardinality.d.ts.map +0 -1
- package/dist/metrics/estimator.d.ts.map +0 -1
- package/dist/metrics/index.d.ts.map +0 -1
- package/dist/metrics/models-dev.d.ts.map +0 -1
- package/dist/metrics/pricing-model.d.ts.map +0 -1
- package/dist/metrics/pricing-registry.d.ts.map +0 -1
- package/dist/metrics/types.d.ts.map +0 -1
- package/dist/metrics/usage-metrics.d.ts.map +0 -1
- package/dist/model-id.d.ts.map +0 -1
- package/dist/model-tracing.d.ts.map +0 -1
- package/dist/recorded.d.ts.map +0 -1
- package/dist/registry.d.ts.map +0 -1
- package/dist/span_processors/index.d.ts.map +0 -1
- package/dist/span_processors/sensitive-data-filter.d.ts.map +0 -1
- package/dist/spans/base.d.ts.map +0 -1
- package/dist/spans/default.d.ts.map +0 -1
- package/dist/spans/index.d.ts.map +0 -1
- package/dist/spans/metadata.d.ts.map +0 -1
- package/dist/spans/no-op.d.ts.map +0 -1
- package/dist/spans/serialization.d.ts.map +0 -1
- package/dist/tracing-options.d.ts.map +0 -1
- package/dist/usage.d.ts.map +0 -1
|
@@ -67,6 +67,14 @@ Executes a synchronous function within the dd-trace context of a Mastra span.
|
|
|
67
67
|
|
|
68
68
|
**Returns:** `T` - The result of the function execution.
|
|
69
69
|
|
|
70
|
+
### `onFeedbackEvent`
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
async onFeedbackEvent(event: FeedbackEvent): Promise<void>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Exports a feedback event to Datadog LLM Observability. See [Feedback export](#feedback-export).
|
|
77
|
+
|
|
70
78
|
### `flush`
|
|
71
79
|
|
|
72
80
|
```typescript
|
|
@@ -199,6 +207,10 @@ This produces:
|
|
|
199
207
|
}
|
|
200
208
|
```
|
|
201
209
|
|
|
210
|
+
## Feedback export
|
|
211
|
+
|
|
212
|
+
Feedback recorded with [`addFeedback()`](https://mastra.ai/docs/observability/feedback) is exported to Datadog as end-user feedback. Feedback with a `spanId` targets that span, and feedback with only a `traceId` targets the trace. The Datadog LLM Observability trace ID is the Mastra trace ID, so late feedback still reaches the run. A run that continues an LLM Observability trace from an upstream service keeps that trace, so only feedback with a `spanId` reaches it. HTTP calls made from inside the run carry its LLM Observability trace ID, so spans from Datadog-instrumented services they call join the run. Fields map the same way as in the [`DatadogExporter`](https://mastra.ai/reference/observability/tracing/exporters/datadog).
|
|
213
|
+
|
|
202
214
|
## Environment variables
|
|
203
215
|
|
|
204
216
|
The bridge reads configuration from these environment variables:
|
|
@@ -38,6 +38,7 @@ interface ObservabilityInstanceConfig {
|
|
|
38
38
|
spanFilter?: (span: AnyExportedSpan) => boolean
|
|
39
39
|
requestContextKeys?: string[]
|
|
40
40
|
serializationOptions?: SerializationOptions
|
|
41
|
+
cardinality?: CardinalityConfig
|
|
41
42
|
logging?: { enabled?: boolean; level?: LogLevel }
|
|
42
43
|
}
|
|
43
44
|
```
|
|
@@ -72,6 +73,12 @@ interface ObservabilityInstanceConfig {
|
|
|
72
73
|
|
|
73
74
|
**serializationOptions.maxObjectKeys** (`number`): Maximum number of keys in objects (default: 50)
|
|
74
75
|
|
|
76
|
+
**cardinality** (`CardinalityConfig`): Controls which metric labels are removed before storage, for both automatic and custom metrics. By default, Mastra removes high-cardinality labels such as trace_id and user_id, and labels whose value is a UUID. See cardinality protection for the defaults.
|
|
77
|
+
|
|
78
|
+
**cardinality.blockedLabels** (`string[]`): Label names to remove. Replaces the default list; spread DEFAULT_BLOCKED_LABELS from @mastra/core/observability to extend it, or pass \[] to allow every label name.
|
|
79
|
+
|
|
80
|
+
**cardinality.blockUUIDs** (`boolean`): Remove labels whose value is a UUID (default: true)
|
|
81
|
+
|
|
75
82
|
**logging** (`{ enabled?: boolean; level?: LogLevel }`): Controls log forwarding to observability storage. See Logging to observability storage for details.
|
|
76
83
|
|
|
77
84
|
**logging.enabled** (`boolean`): Set to false to disable log forwarding to observability storage (default: true)
|
|
@@ -44,6 +44,14 @@ async exportTracingEvent(event: TracingEvent): Promise<void>
|
|
|
44
44
|
|
|
45
45
|
Exports a tracing event to Datadog LLM Observability.
|
|
46
46
|
|
|
47
|
+
### `onFeedbackEvent`
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
async onFeedbackEvent(event: FeedbackEvent): Promise<void>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Exports a feedback event to Datadog LLM Observability. See [Feedback export](#feedback-export).
|
|
54
|
+
|
|
47
55
|
### flush
|
|
48
56
|
|
|
49
57
|
```typescript
|
|
@@ -113,6 +121,48 @@ Mastra span types are mapped to Datadog LLM Observability span kinds:
|
|
|
113
121
|
|
|
114
122
|
All unmapped span types (including `MODEL_CHUNK`, `WORKFLOW_STEP`, `GENERIC`, and future span types) automatically default to `task`.
|
|
115
123
|
|
|
124
|
+
## Feedback export
|
|
125
|
+
|
|
126
|
+
Feedback recorded with [`addFeedback()`](https://mastra.ai/docs/observability/feedback) is exported to Datadog as end-user feedback. Feedback with a `spanId` targets that span, and feedback with only a `traceId` targets the trace. No extra configuration is needed.
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
if (!mastra.observability.addFeedback) {
|
|
130
|
+
throw new Error('Feedback is not supported by the active observability implementation')
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
await mastra.observability.addFeedback({
|
|
134
|
+
traceId,
|
|
135
|
+
feedback: {
|
|
136
|
+
feedbackType: 'thumbs',
|
|
137
|
+
value: 'down',
|
|
138
|
+
comment: 'Wrong answer',
|
|
139
|
+
feedbackUserId: 'user-123',
|
|
140
|
+
metadata: { datadog: { assessment: 'fail' } },
|
|
141
|
+
},
|
|
142
|
+
})
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
The Datadog LLM Observability trace ID is the Mastra trace ID, and each Datadog span ID is the Mastra span ID. Feedback reaches its trace or span even when it arrives hours after the run or from another process. You can also search Datadog for the `traceId` that a run returns.
|
|
146
|
+
|
|
147
|
+
| Mastra feedback field | Datadog feedback field |
|
|
148
|
+
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
149
|
+
| `traceId` | `trace_id`, the target when there is no `spanId` |
|
|
150
|
+
| `spanId` | `span_id`, the target span |
|
|
151
|
+
| `feedbackType` | `label`, with each `.` changed to `_` |
|
|
152
|
+
| `value` | `score_value` for numbers, `text_value` for `comment` and `correction` feedback, `categorical_value` for other strings |
|
|
153
|
+
| `comment` | `reasoning` |
|
|
154
|
+
| `feedbackUserId` (or `metadata.userId`) | `submitter.id`, or `anonymous` when neither is set or `feedbackUserId` is `null` |
|
|
155
|
+
| `feedbackSource` | `feedback_source` tag |
|
|
156
|
+
| `metadata.datadog.assessment` | `assessment`, when the value is `pass` or `fail` |
|
|
157
|
+
|
|
158
|
+
The `assessment` is optional. Your app decides which feedback passes or fails, and Mastra doesn't derive it from the value. Set it on the feedback, not on the run, because feedback can inherit the metadata of the run it rates. To find failed feedback with the `thumbs` label in Datadog, search for `@feedback.thumbs.assessment:fail`.
|
|
159
|
+
|
|
160
|
+
Feedback without a `traceId` is dropped. Feedback without a `spanId` can't reach a run that joined another LLM Observability trace, such as a run inside your own `llmobs.trace()` call or one continued from an upstream service. Those runs keep the Datadog trace ID that `dd-trace` gives them.
|
|
161
|
+
|
|
162
|
+
## Score export
|
|
163
|
+
|
|
164
|
+
Scores recorded with `mastra.observability.addScore()` are exported to Datadog as evaluations on the span they rate. A score reaches its span even when it arrives after the run or from another process. A late score can't reach a run that joined another LLM Observability trace.
|
|
165
|
+
|
|
116
166
|
## Environment variables
|
|
117
167
|
|
|
118
168
|
The exporter reads configuration from these environment variables:
|