@mastra/observability 1.24.1-alpha.0 → 1.24.1-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/dist/bus/observability-bus.d.ts +1 -1
- package/dist/bus/observability-bus.d.ts.map +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +30 -30
- package/dist/docs/references/docs-observability-integrations-exporters-mastra-storage.md +28 -9
- package/dist/docs/references/docs-observability-tracing-overview.md +1 -0
- package/dist/docs/references/integrations-observability-opentelemetry.md +214 -187
- package/dist/docs/references/reference-observability-feedback.md +13 -0
- package/dist/docs/references/reference-observability-tracing-exporters-mastra-storage-exporter.md +5 -2
- package/dist/docs/references/reference-observability-tracing-exporters-sentry.md +2 -2
- package/dist/exporters/event-buffer.d.ts +16 -1
- package/dist/exporters/event-buffer.d.ts.map +1 -1
- package/dist/exporters/mastra-storage.d.ts +17 -7
- package/dist/exporters/mastra-storage.d.ts.map +1 -1
- package/dist/index.cjs +145 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +145 -43
- package/dist/index.js.map +1 -1
- package/dist/instances/base.d.ts +1 -0
- package/dist/instances/base.d.ts.map +1 -1
- package/dist/spans/base.d.ts +1 -1
- package/package.json +3 -3
|
@@ -8,13 +8,13 @@ Mastra supports OpenTelemetry (OTEL) through an exporter for sending traces and
|
|
|
8
8
|
|
|
9
9
|
## Exporter
|
|
10
10
|
|
|
11
|
-
The OpenTelemetry exporter sends your traces and logs using standardized [OpenTelemetry Semantic Conventions for GenAI](https://opentelemetry.io/docs/specs/semconv/gen-ai/). This ensures broad compatibility with platforms like
|
|
11
|
+
The OpenTelemetry exporter sends your traces and logs using standardized [OpenTelemetry Semantic Conventions for GenAI](https://opentelemetry.io/docs/specs/semconv/gen-ai/). This ensures broad compatibility with platforms like Agnost AI, Dash0, Datadog, Laminar, Latitude, MLflow, New Relic, Sazabi, Sentry, SigNoz, telemetry.dev, Traceloop, and more.
|
|
12
12
|
|
|
13
13
|
### Installation
|
|
14
14
|
|
|
15
15
|
Each provider requires specific protocol packages. Install the base exporter plus the protocol package for your provider:
|
|
16
16
|
|
|
17
|
-
#### For HTTP/Protobuf providers (
|
|
17
|
+
#### For HTTP/Protobuf providers (Agnost AI, Laminar, Latitude, MLflow, New Relic, Sentry, SigNoz, telemetry.dev)
|
|
18
18
|
|
|
19
19
|
**npm**:
|
|
20
20
|
|
|
@@ -66,7 +66,7 @@ yarn add @mastra/otel-exporter@latest @opentelemetry/exporter-trace-otlp-grpc @g
|
|
|
66
66
|
bun add @mastra/otel-exporter@latest @opentelemetry/exporter-trace-otlp-grpc @grpc/grpc-js
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
#### For HTTP/JSON providers (
|
|
69
|
+
#### For HTTP/JSON providers (Sazabi, Traceloop)
|
|
70
70
|
|
|
71
71
|
**npm**:
|
|
72
72
|
|
|
@@ -99,128 +99,37 @@ All providers support zero-config setup via environment variables. Set the appro
|
|
|
99
99
|
| Provider | Environment Variables |
|
|
100
100
|
| --------- | ------------------------------------------------------------------------------------------- |
|
|
101
101
|
| Dash0 | `DASH0_API_KEY` (required), `DASH0_ENDPOINT` (required), `DASH0_DATASET` (optional) |
|
|
102
|
-
|
|
|
102
|
+
| Laminar | `LMNR_PROJECT_API_KEY` (required), `LAMINAR_ENDPOINT` (optional) |
|
|
103
103
|
| New Relic | `NEW_RELIC_LICENSE_KEY` (required), `NEW_RELIC_ENDPOINT` (optional) |
|
|
104
|
+
| SigNoz | `SIGNOZ_API_KEY` (required), `SIGNOZ_REGION` (optional), `SIGNOZ_ENDPOINT` (optional) |
|
|
104
105
|
| Traceloop | `TRACELOOP_API_KEY` (required), `TRACELOOP_DESTINATION_ID`, `TRACELOOP_ENDPOINT` (optional) |
|
|
105
|
-
| Laminar | `LMNR_PROJECT_API_KEY` (required), `LAMINAR_ENDPOINT` (optional) |
|
|
106
106
|
|
|
107
107
|
### Provider configurations
|
|
108
108
|
|
|
109
|
-
####
|
|
109
|
+
#### Agnost AI
|
|
110
110
|
|
|
111
|
-
[
|
|
111
|
+
[Agnost AI](https://agnost.ai) ingests OTLP/HTTP protobuf traces and groups them into conversations and users for production agent monitoring. Use the `custom` provider with your organization ID:
|
|
112
112
|
|
|
113
113
|
```bash
|
|
114
|
-
|
|
115
|
-
SENTRY_OTLP_AUTH_HEADER="sentry sentry_key=..."
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
Use the `custom` provider with HTTP/Protobuf:
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
new OtelExporter({
|
|
122
|
-
provider: {
|
|
123
|
-
custom: {
|
|
124
|
-
endpoint: process.env.SENTRY_OTLP_ENDPOINT!,
|
|
125
|
-
protocol: 'http/protobuf',
|
|
126
|
-
headers: {
|
|
127
|
-
'x-sentry-auth': process.env.SENTRY_OTLP_AUTH_HEADER!,
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
})
|
|
114
|
+
AGNOST_ORG_ID=your-org-id
|
|
132
115
|
```
|
|
133
116
|
|
|
134
|
-
See [Sentry's OTLP documentation](https://docs.sentry.io/concepts/otlp/) for endpoint setup, supported signals, and current ingestion limits.
|
|
135
|
-
|
|
136
|
-
Choose an exporter based on your setup:
|
|
137
|
-
|
|
138
|
-
- `OtelExporter`: Sends vendor-neutral traces and logs over OTLP. Use it with an existing OpenTelemetry pipeline or when you want backend portability.
|
|
139
|
-
- [`SentryExporter`](https://mastra.ai/integrations/observability/sentry): Uses the Sentry SDK to map Mastra span types to Sentry operations, add AI monitoring attributes, and capture span errors as Sentry issues.
|
|
140
|
-
|
|
141
|
-
#### MLflow
|
|
142
|
-
|
|
143
|
-
[MLflow](https://mlflow.org/docs/latest/genai/tracing/integrations/listing/mastra) supports native Mastra tracing through its OTLP endpoint at `/v1/traces`. Use the `custom` provider with HTTP/Protobuf and include the experiment header so traces are routed to the correct MLflow experiment:
|
|
144
|
-
|
|
145
117
|
```typescript
|
|
146
118
|
new OtelExporter({
|
|
147
119
|
provider: {
|
|
148
120
|
custom: {
|
|
149
|
-
endpoint:
|
|
121
|
+
endpoint: 'https://otel.agnost.ai/v1/traces',
|
|
150
122
|
protocol: 'http/protobuf',
|
|
151
123
|
headers: {
|
|
152
|
-
'
|
|
124
|
+
'X-Agnost-Org-ID': process.env.AGNOST_ORG_ID!,
|
|
153
125
|
},
|
|
154
126
|
},
|
|
155
127
|
},
|
|
128
|
+
signals: { logs: false },
|
|
156
129
|
})
|
|
157
130
|
```
|
|
158
131
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
[Latitude](https://latitude.so) is an open-source LLM observability and evaluation platform that ingests OTLP traces. Use the `custom` provider with HTTP/Protobuf, pointing at Latitude's ingestion endpoint and authenticating with your API key and project slug:
|
|
162
|
-
|
|
163
|
-
```typescript
|
|
164
|
-
new OtelExporter({
|
|
165
|
-
provider: {
|
|
166
|
-
custom: {
|
|
167
|
-
endpoint: 'https://ingest.latitude.so/v1/traces',
|
|
168
|
-
protocol: 'http/protobuf',
|
|
169
|
-
headers: {
|
|
170
|
-
Authorization: `Bearer ${process.env.LATITUDE_API_KEY}`,
|
|
171
|
-
'X-Latitude-Project': process.env.LATITUDE_PROJECT,
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
})
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
Sign up at [console.latitude.so](https://console.latitude.so/login), or self-host and point the endpoint at your own ingestion host.
|
|
179
|
-
|
|
180
|
-
#### telemetry.dev
|
|
181
|
-
|
|
182
|
-
[telemetry.dev](https://telemetry.dev) ingests OTLP/HTTP protobuf traces and normalizes OpenTelemetry GenAI semantic conventions into model, provider, token, latency, and cost fields. Use the `custom` provider with your project API key:
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
TELEMETRY_DEV_API_KEY=td_live_...
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
```typescript
|
|
189
|
-
new OtelExporter({
|
|
190
|
-
provider: {
|
|
191
|
-
custom: {
|
|
192
|
-
endpoint: 'https://ingest.telemetry.dev/v1/traces',
|
|
193
|
-
protocol: 'http/protobuf',
|
|
194
|
-
headers: {
|
|
195
|
-
Authorization: `Bearer ${process.env.TELEMETRY_DEV_API_KEY}`,
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
})
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
#### Sazabi
|
|
203
|
-
|
|
204
|
-
[Sazabi](https://sazabi.com) is an AI-native observability platform that ingests OTLP traces. In Sazabi, add a Mastra log source and copy its intake URL. The URL carries your project key, so no auth header is needed:
|
|
205
|
-
|
|
206
|
-
```bash
|
|
207
|
-
SAZABI_INTAKE_URL=https://...
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
Use the `custom` provider with HTTP/JSON:
|
|
211
|
-
|
|
212
|
-
```typescript
|
|
213
|
-
new OtelExporter({
|
|
214
|
-
provider: {
|
|
215
|
-
custom: {
|
|
216
|
-
endpoint: process.env.SAZABI_INTAKE_URL!,
|
|
217
|
-
protocol: 'http/json',
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
})
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
See [Sazabi's Mastra guide](https://docs.sazabi.com/catalogs/log-sources/send-to-an-endpoint/mastra) for the full setup.
|
|
132
|
+
Agnost AI reads `userId` and `conversationId` (or `threadId`) from `tracingOptions.metadata` to group traces by user and conversation. It stores traces only, so `signals: { logs: false }` skips the log export. See [Agnost AI's Mastra guide](https://docs.agnost.ai/mastra) for the full setup.
|
|
224
133
|
|
|
225
134
|
#### Dash0
|
|
226
135
|
|
|
@@ -291,23 +200,78 @@ export const mastra = new Mastra({
|
|
|
291
200
|
|
|
292
201
|
> **Note:** Get your Dash0 endpoint from your dashboard. It should be in the format `ingress.{region}.aws.dash0.com:4317`.
|
|
293
202
|
|
|
294
|
-
####
|
|
203
|
+
#### Datadog
|
|
295
204
|
|
|
296
|
-
[
|
|
205
|
+
[Datadog](https://www.datadoghq.com/) APM provides application performance monitoring with distributed tracing. To send traces to Datadog via OTLP, you need the Datadog Agent running with OTLP ingestion enabled.
|
|
206
|
+
|
|
207
|
+
Datadog uses gRPC for OTLP ingestion, which requires explicit imports and [bundler configuration](https://mastra.ai/reference/configuration) to work correctly:
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
// Explicitly import gRPC dependencies for the bundler
|
|
211
|
+
import '@grpc/grpc-js'
|
|
212
|
+
import '@opentelemetry/exporter-trace-otlp-grpc'
|
|
213
|
+
import { Mastra } from '@mastra/core'
|
|
214
|
+
import { Observability } from '@mastra/observability'
|
|
215
|
+
import { OtelExporter, type ExportProtocol } from '@mastra/otel-exporter'
|
|
216
|
+
|
|
217
|
+
export const mastra = new Mastra({
|
|
218
|
+
// Add grpc-js to externals so it's handled at runtime
|
|
219
|
+
bundler: {
|
|
220
|
+
externals: ['@grpc/grpc-js'],
|
|
221
|
+
},
|
|
222
|
+
observability: new Observability({
|
|
223
|
+
configs: {
|
|
224
|
+
default: {
|
|
225
|
+
serviceName: 'my-service',
|
|
226
|
+
exporters: [
|
|
227
|
+
new OtelExporter({
|
|
228
|
+
provider: {
|
|
229
|
+
custom: {
|
|
230
|
+
endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4317',
|
|
231
|
+
protocol: (process.env.OTEL_EXPORTER_OTLP_PROTOCOL || 'grpc') as ExportProtocol,
|
|
232
|
+
headers: {},
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
}),
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
}),
|
|
240
|
+
})
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
> **Note:** The Datadog Agent must be configured with OTLP ingestion enabled. Add the following to your `datadog.yaml`:
|
|
244
|
+
>
|
|
245
|
+
> ```yaml
|
|
246
|
+
> otlp_config:
|
|
247
|
+
> receiver:
|
|
248
|
+
> protocols:
|
|
249
|
+
> grpc:
|
|
250
|
+
> endpoint: 0.0.0.0:4317
|
|
251
|
+
> ```
|
|
252
|
+
>
|
|
253
|
+
> The default OTLP endpoint is `http://localhost:4317` when running the Datadog Agent locally.
|
|
254
|
+
|
|
255
|
+
> **Warning:** The explicit imports of `@grpc/grpc-js` and `@opentelemetry/exporter-trace-otlp-grpc` at the top of the file, along with the [`bundler.externals`](https://mastra.ai/reference/configuration) configuration, are required for the gRPC transport to work correctly. Without these, you may encounter connection issues.
|
|
256
|
+
|
|
257
|
+
> **Datadog-Native Exporter:** For Datadog-specific features like automatic span type mapping, LLM span categorization, and simplified setup without gRPC configuration, consider using the dedicated [`@mastra/datadog`](https://mastra.ai/integrations/observability/datadog) exporter instead. It provides optimized integration with Datadog's APM platform.
|
|
258
|
+
|
|
259
|
+
#### Laminar
|
|
260
|
+
|
|
261
|
+
[Laminar](https://laminar.sh/) provides specialized LLM observability and analytics.
|
|
297
262
|
|
|
298
263
|
##### Zero-Config Setup
|
|
299
264
|
|
|
300
265
|
```bash
|
|
301
266
|
# Required
|
|
302
|
-
|
|
267
|
+
LMNR_PROJECT_API_KEY=your-api-key
|
|
303
268
|
|
|
304
269
|
# Optional
|
|
305
|
-
|
|
306
|
-
SIGNOZ_ENDPOINT=https://my-signoz.example.com # For self-hosted
|
|
270
|
+
LAMINAR_ENDPOINT=https://api.lmnr.ai/v1/traces
|
|
307
271
|
```
|
|
308
272
|
|
|
309
273
|
```typescript
|
|
310
|
-
new OtelExporter({ provider: {
|
|
274
|
+
new OtelExporter({ provider: { laminar: {} } })
|
|
311
275
|
```
|
|
312
276
|
|
|
313
277
|
##### Explicit Configuration
|
|
@@ -315,10 +279,49 @@ new OtelExporter({ provider: { signoz: {} } })
|
|
|
315
279
|
```typescript
|
|
316
280
|
new OtelExporter({
|
|
317
281
|
provider: {
|
|
318
|
-
|
|
319
|
-
apiKey: process.env.
|
|
320
|
-
|
|
321
|
-
|
|
282
|
+
laminar: {
|
|
283
|
+
apiKey: process.env.LMNR_PROJECT_API_KEY,
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
})
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
> **Laminar-Native Exporter:** For Laminar-specific features like native span paths, metadata, and tags rendering in the Laminar dashboard, consider using the dedicated [`@mastra/laminar`](https://mastra.ai/integrations/observability/laminar) exporter instead. It provides optimized integration with Laminar's platform.
|
|
290
|
+
|
|
291
|
+
#### Latitude
|
|
292
|
+
|
|
293
|
+
[Latitude](https://latitude.so) is an open-source LLM observability and evaluation platform that ingests OTLP traces. Use the `custom` provider with HTTP/Protobuf, pointing at Latitude's ingestion endpoint and authenticating with your API key and project slug:
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
new OtelExporter({
|
|
297
|
+
provider: {
|
|
298
|
+
custom: {
|
|
299
|
+
endpoint: 'https://ingest.latitude.so/v1/traces',
|
|
300
|
+
protocol: 'http/protobuf',
|
|
301
|
+
headers: {
|
|
302
|
+
Authorization: `Bearer ${process.env.LATITUDE_API_KEY}`,
|
|
303
|
+
'X-Latitude-Project': process.env.LATITUDE_PROJECT,
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
})
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Sign up at [console.latitude.so](https://console.latitude.so/login), or self-host and point the endpoint at your own ingestion host.
|
|
311
|
+
|
|
312
|
+
#### MLflow
|
|
313
|
+
|
|
314
|
+
[MLflow](https://mlflow.org/docs/latest/genai/tracing/integrations/listing/mastra) supports native Mastra tracing through its OTLP endpoint at `/v1/traces`. Use the `custom` provider with HTTP/Protobuf and include the experiment header so traces are routed to the correct MLflow experiment:
|
|
315
|
+
|
|
316
|
+
```typescript
|
|
317
|
+
new OtelExporter({
|
|
318
|
+
provider: {
|
|
319
|
+
custom: {
|
|
320
|
+
endpoint: `${process.env.MLFLOW_TRACKING_URI}/v1/traces`,
|
|
321
|
+
protocol: 'http/protobuf',
|
|
322
|
+
headers: {
|
|
323
|
+
'x-mlflow-experiment-id': process.env.MLFLOW_EXPERIMENT_ID,
|
|
324
|
+
},
|
|
322
325
|
},
|
|
323
326
|
},
|
|
324
327
|
})
|
|
@@ -355,54 +358,78 @@ new OtelExporter({
|
|
|
355
358
|
})
|
|
356
359
|
```
|
|
357
360
|
|
|
358
|
-
####
|
|
359
|
-
|
|
360
|
-
[Traceloop](https://www.traceloop.com/) specializes in LLM observability with automatic prompt tracking.
|
|
361
|
+
#### Sazabi
|
|
361
362
|
|
|
362
|
-
|
|
363
|
+
[Sazabi](https://sazabi.com) is an AI-native observability platform that ingests OTLP traces. In Sazabi, add a Mastra log source and copy its intake URL. The URL carries your project key, so no auth header is needed:
|
|
363
364
|
|
|
364
365
|
```bash
|
|
365
|
-
|
|
366
|
-
TRACELOOP_API_KEY=your-api-key
|
|
367
|
-
|
|
368
|
-
# Optional
|
|
369
|
-
TRACELOOP_DESTINATION_ID=my-destination
|
|
370
|
-
TRACELOOP_ENDPOINT=https://custom.traceloop.com
|
|
366
|
+
SAZABI_INTAKE_URL=https://...
|
|
371
367
|
```
|
|
372
368
|
|
|
369
|
+
Use the `custom` provider with HTTP/JSON:
|
|
370
|
+
|
|
373
371
|
```typescript
|
|
374
|
-
new OtelExporter({
|
|
372
|
+
new OtelExporter({
|
|
373
|
+
provider: {
|
|
374
|
+
custom: {
|
|
375
|
+
endpoint: process.env.SAZABI_INTAKE_URL!,
|
|
376
|
+
protocol: 'http/json',
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
})
|
|
375
380
|
```
|
|
376
381
|
|
|
377
|
-
|
|
382
|
+
See [Sazabi's Mastra guide](https://docs.sazabi.com/catalogs/log-sources/send-to-an-endpoint/mastra) for the full setup.
|
|
383
|
+
|
|
384
|
+
#### Sentry
|
|
385
|
+
|
|
386
|
+
[Sentry](https://sentry.io/) accepts OpenTelemetry traces and logs through its OTLP endpoints. In Sentry, open [**Project Settings** > **Client Keys (DSN)**](https://sentry.io/settings/projects/) and copy the OTLP traces endpoint and authentication header. Add both values to your environment:
|
|
387
|
+
|
|
388
|
+
```bash
|
|
389
|
+
SENTRY_OTLP_ENDPOINT=https://o000000.ingest.sentry.io/api/0000000/integration/otlp/v1/traces
|
|
390
|
+
SENTRY_OTLP_AUTH_HEADER="sentry sentry_key=..."
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
Use the `custom` provider with HTTP/Protobuf:
|
|
378
394
|
|
|
379
395
|
```typescript
|
|
380
396
|
new OtelExporter({
|
|
381
397
|
provider: {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
398
|
+
custom: {
|
|
399
|
+
endpoint: process.env.SENTRY_OTLP_ENDPOINT!,
|
|
400
|
+
protocol: 'http/protobuf',
|
|
401
|
+
headers: {
|
|
402
|
+
'x-sentry-auth': process.env.SENTRY_OTLP_AUTH_HEADER!,
|
|
403
|
+
},
|
|
385
404
|
},
|
|
386
405
|
},
|
|
387
406
|
})
|
|
388
407
|
```
|
|
389
408
|
|
|
390
|
-
|
|
409
|
+
See [Sentry's OTLP documentation](https://docs.sentry.io/concepts/otlp/) for endpoint setup, supported signals, and current ingestion limits.
|
|
391
410
|
|
|
392
|
-
|
|
411
|
+
Choose an exporter based on your setup:
|
|
412
|
+
|
|
413
|
+
- `OtelExporter`: Sends vendor-neutral traces and logs over OTLP. Use it with an existing OpenTelemetry pipeline or when you want backend portability.
|
|
414
|
+
- [`SentryExporter`](https://mastra.ai/integrations/observability/sentry): Uses the Sentry SDK to map Mastra span types to Sentry operations, add AI monitoring attributes, and capture span errors as Sentry issues.
|
|
415
|
+
|
|
416
|
+
#### SigNoz
|
|
417
|
+
|
|
418
|
+
[SigNoz](https://signoz.io/) is an open-source APM alternative with built-in Tracing support.
|
|
393
419
|
|
|
394
420
|
##### Zero-Config Setup
|
|
395
421
|
|
|
396
422
|
```bash
|
|
397
423
|
# Required
|
|
398
|
-
|
|
424
|
+
SIGNOZ_API_KEY=your-api-key
|
|
399
425
|
|
|
400
426
|
# Optional
|
|
401
|
-
|
|
427
|
+
SIGNOZ_REGION=us # 'us' | 'eu' | 'in'
|
|
428
|
+
SIGNOZ_ENDPOINT=https://my-signoz.example.com # For self-hosted
|
|
402
429
|
```
|
|
403
430
|
|
|
404
431
|
```typescript
|
|
405
|
-
new OtelExporter({ provider: {
|
|
432
|
+
new OtelExporter({ provider: { signoz: {} } })
|
|
406
433
|
```
|
|
407
434
|
|
|
408
435
|
##### Explicit Configuration
|
|
@@ -410,70 +437,68 @@ new OtelExporter({ provider: { laminar: {} } })
|
|
|
410
437
|
```typescript
|
|
411
438
|
new OtelExporter({
|
|
412
439
|
provider: {
|
|
413
|
-
|
|
414
|
-
apiKey: process.env.
|
|
440
|
+
signoz: {
|
|
441
|
+
apiKey: process.env.SIGNOZ_API_KEY,
|
|
442
|
+
region: 'us', // 'us' | 'eu' | 'in'
|
|
443
|
+
// endpoint: 'https://my-signoz.example.com', // For self-hosted
|
|
415
444
|
},
|
|
416
445
|
},
|
|
417
446
|
})
|
|
418
447
|
```
|
|
419
448
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
#### Datadog
|
|
449
|
+
#### telemetry.dev
|
|
423
450
|
|
|
424
|
-
[
|
|
451
|
+
[telemetry.dev](https://telemetry.dev) ingests OTLP/HTTP protobuf traces and normalizes OpenTelemetry GenAI semantic conventions into model, provider, token, latency, and cost fields. Use the `custom` provider with your project API key:
|
|
425
452
|
|
|
426
|
-
|
|
453
|
+
```bash
|
|
454
|
+
TELEMETRY_DEV_API_KEY=td_live_...
|
|
455
|
+
```
|
|
427
456
|
|
|
428
457
|
```typescript
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
export const mastra = new Mastra({
|
|
437
|
-
// Add grpc-js to externals so it's handled at runtime
|
|
438
|
-
bundler: {
|
|
439
|
-
externals: ['@grpc/grpc-js'],
|
|
440
|
-
},
|
|
441
|
-
observability: new Observability({
|
|
442
|
-
configs: {
|
|
443
|
-
default: {
|
|
444
|
-
serviceName: 'my-service',
|
|
445
|
-
exporters: [
|
|
446
|
-
new OtelExporter({
|
|
447
|
-
provider: {
|
|
448
|
-
custom: {
|
|
449
|
-
endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4317',
|
|
450
|
-
protocol: (process.env.OTEL_EXPORTER_OTLP_PROTOCOL || 'grpc') as ExportProtocol,
|
|
451
|
-
headers: {},
|
|
452
|
-
},
|
|
453
|
-
},
|
|
454
|
-
}),
|
|
455
|
-
],
|
|
458
|
+
new OtelExporter({
|
|
459
|
+
provider: {
|
|
460
|
+
custom: {
|
|
461
|
+
endpoint: 'https://ingest.telemetry.dev/v1/traces',
|
|
462
|
+
protocol: 'http/protobuf',
|
|
463
|
+
headers: {
|
|
464
|
+
Authorization: `Bearer ${process.env.TELEMETRY_DEV_API_KEY}`,
|
|
456
465
|
},
|
|
457
466
|
},
|
|
458
|
-
}
|
|
467
|
+
},
|
|
459
468
|
})
|
|
460
469
|
```
|
|
461
470
|
|
|
462
|
-
|
|
463
|
-
>
|
|
464
|
-
> ```yaml
|
|
465
|
-
> otlp_config:
|
|
466
|
-
> receiver:
|
|
467
|
-
> protocols:
|
|
468
|
-
> grpc:
|
|
469
|
-
> endpoint: 0.0.0.0:4317
|
|
470
|
-
> ```
|
|
471
|
-
>
|
|
472
|
-
> The default OTLP endpoint is `http://localhost:4317` when running the Datadog Agent locally.
|
|
471
|
+
#### Traceloop
|
|
473
472
|
|
|
474
|
-
|
|
473
|
+
[Traceloop](https://www.traceloop.com/) specializes in LLM observability with automatic prompt tracking.
|
|
475
474
|
|
|
476
|
-
|
|
475
|
+
##### Zero-Config Setup
|
|
476
|
+
|
|
477
|
+
```bash
|
|
478
|
+
# Required
|
|
479
|
+
TRACELOOP_API_KEY=your-api-key
|
|
480
|
+
|
|
481
|
+
# Optional
|
|
482
|
+
TRACELOOP_DESTINATION_ID=my-destination
|
|
483
|
+
TRACELOOP_ENDPOINT=https://custom.traceloop.com
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
```typescript
|
|
487
|
+
new OtelExporter({ provider: { traceloop: {} } })
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
##### Explicit Configuration
|
|
491
|
+
|
|
492
|
+
```typescript
|
|
493
|
+
new OtelExporter({
|
|
494
|
+
provider: {
|
|
495
|
+
traceloop: {
|
|
496
|
+
apiKey: process.env.TRACELOOP_API_KEY,
|
|
497
|
+
destinationId: 'my-destination', // Optional
|
|
498
|
+
},
|
|
499
|
+
},
|
|
500
|
+
})
|
|
501
|
+
```
|
|
477
502
|
|
|
478
503
|
#### Custom/Generic OTEL Endpoints
|
|
479
504
|
|
|
@@ -570,7 +595,7 @@ If the matching log exporter package isn't installed, log export is silently dis
|
|
|
570
595
|
new OtelExporter({
|
|
571
596
|
// Provider configuration (required)
|
|
572
597
|
provider: {
|
|
573
|
-
// Use one of: dash0,
|
|
598
|
+
// Use one of: dash0, laminar, newrelic, signoz, traceloop, custom
|
|
574
599
|
},
|
|
575
600
|
|
|
576
601
|
// Per-signal toggles. Both default to true.
|
|
@@ -590,7 +615,9 @@ new OtelExporter({
|
|
|
590
615
|
|
|
591
616
|
### `OpenTelemetry` semantic conventions
|
|
592
617
|
|
|
593
|
-
The exporter follows [OpenTelemetry Semantic Conventions for GenAI v1.
|
|
618
|
+
The exporter follows [OpenTelemetry Semantic Conventions for GenAI v1.41.0](https://github.com/open-telemetry/semantic-conventions/tree/v1.41.0/docs/gen-ai). Traces and logs exported over OTLP declare this version with the schema URL `https://opentelemetry.io/schemas/1.41.0`, so backends that read attributes by version read them correctly. Traces sent through a custom `exporter` declare no version, because that exporter can change the attributes.
|
|
619
|
+
|
|
620
|
+
The conventions cover the following span names and attributes:
|
|
594
621
|
|
|
595
622
|
#### Span Naming
|
|
596
623
|
|
|
@@ -622,10 +649,10 @@ Choose the right protocol package based on your provider:
|
|
|
622
649
|
| --------- | ------------- | ------------------------------------------ |
|
|
623
650
|
| Dash0 | gRPC | `@opentelemetry/exporter-trace-otlp-grpc` |
|
|
624
651
|
| Datadog | gRPC | `@opentelemetry/exporter-trace-otlp-grpc` |
|
|
625
|
-
|
|
|
652
|
+
| Laminar | HTTP/Protobuf | `@opentelemetry/exporter-trace-otlp-proto` |
|
|
626
653
|
| New Relic | HTTP/Protobuf | `@opentelemetry/exporter-trace-otlp-proto` |
|
|
654
|
+
| SigNoz | HTTP/Protobuf | `@opentelemetry/exporter-trace-otlp-proto` |
|
|
627
655
|
| Traceloop | HTTP/JSON | `@opentelemetry/exporter-trace-otlp-http` |
|
|
628
|
-
| Laminar | HTTP/Protobuf | `@opentelemetry/exporter-trace-otlp-proto` |
|
|
629
656
|
| Custom | Varies | Depends on your collector |
|
|
630
657
|
|
|
631
658
|
> **Warning:** Make sure to install the correct protocol package for your provider. The exporter will provide a helpful error message if the wrong package is installed.
|
|
@@ -654,7 +681,7 @@ Install the suggested package for your provider.
|
|
|
654
681
|
|
|
655
682
|
- [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
|
|
656
683
|
- [OpenTelemetry Bridge](#bridge)
|
|
657
|
-
- [OpenTelemetry Semantic Conventions for GenAI v1.
|
|
684
|
+
- [OpenTelemetry Semantic Conventions for GenAI v1.41.0](https://github.com/open-telemetry/semantic-conventions/tree/v1.41.0/docs/gen-ai)
|
|
658
685
|
- [OTEL Exporter Reference](https://mastra.ai/reference/observability/tracing/exporters/otel)
|
|
659
686
|
|
|
660
687
|
## Bridge
|
|
@@ -826,7 +853,7 @@ Mastra's `flush()` and `shutdown()` ask the registered OTEL providers to flush,
|
|
|
826
853
|
|
|
827
854
|
### Semantic conventions
|
|
828
855
|
|
|
829
|
-
The `OtelBridge` exports Mastra spans using [OpenTelemetry Semantic Conventions for GenAI v1.
|
|
856
|
+
The `OtelBridge` exports Mastra spans using [OpenTelemetry Semantic Conventions for GenAI v1.41.0](https://github.com/open-telemetry/semantic-conventions/tree/v1.41.0/docs/gen-ai). This includes standardized span names (`chat {model}`, `execute_tool {tool_name}`, etc.) and attributes (`gen_ai.usage.input_tokens`, `gen_ai.request.model`, etc.).
|
|
830
857
|
|
|
831
858
|
For details on span naming and attributes, see the [OpenTelemetry Exporter semantic conventions](#opentelemetry-semantic-conventions).
|
|
832
859
|
|
|
@@ -154,6 +154,18 @@ await mastraClient.deleteScores({
|
|
|
154
154
|
})
|
|
155
155
|
```
|
|
156
156
|
|
|
157
|
+
## Get feedback
|
|
158
|
+
|
|
159
|
+
### `getFeedback(feedbackId)`
|
|
160
|
+
|
|
161
|
+
Returns one feedback record by ID. The response's `feedback` field is `null` when no record matches.
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
const { feedback } = await mastraClient.getFeedback('feedback-1')
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Observability storage exposes the same lookup as `await storage.getFeedbackById(feedbackId)`, which resolves to the `FeedbackRecord` or `null`. `PostgresStoreVNext`, `ClickhouseStoreVNext`, and the DuckDB and in-memory observability stores support it. Other stores, including the legacy `PostgresStore` and `ClickhouseStore` and LibSQL, throw `OBSERVABILITY_STORAGE_GET_FEEDBACK_BY_ID_NOT_IMPLEMENTED`, and the client request fails instead of returning `null`.
|
|
168
|
+
|
|
157
169
|
## List feedback
|
|
158
170
|
|
|
159
171
|
### `listFeedback(args?)`
|
|
@@ -462,6 +474,7 @@ These routes belong to a Mastra runtime and use its configured observability sto
|
|
|
462
474
|
| Method | Path | Purpose | Permission |
|
|
463
475
|
| -------- | ------------------------------------------------------- | ---------------------------------- | ---------------------- |
|
|
464
476
|
| `GET` | `/api/observability/feedback` | List feedback records | `observability:read` |
|
|
477
|
+
| `GET` | `/api/observability/feedback/:feedbackId` | Get one feedback record | `observability:read` |
|
|
465
478
|
| `POST` | `/api/observability/feedback` | Create a feedback record | `observability:write` |
|
|
466
479
|
| `PUT` | `/api/observability/feedback/:feedbackId` | Replace a complete feedback record | `observability:write` |
|
|
467
480
|
| `DELETE` | `/api/observability/feedback` | Delete feedback records by id | `observability:delete` |
|
package/dist/docs/references/reference-observability-tracing-exporters-mastra-storage-exporter.md
CHANGED
|
@@ -85,7 +85,7 @@ type TracingStorageStrategy = 'realtime' | 'batch-with-updates' | 'insert-only'
|
|
|
85
85
|
|
|
86
86
|
### Strategy Behaviors
|
|
87
87
|
|
|
88
|
-
- **realtime**: Immediately persists each event to storage
|
|
88
|
+
- **realtime**: Immediately persists each event to storage. Use it only in single-process local development. It isn't supported with durable execution: when a durable agent or an Inngest, Temporal, or evented workflow is registered, the exporter logs one warning and runs `batch-with-updates`.
|
|
89
89
|
- **batch-with-updates**: Batches creates and updates separately, applies in order
|
|
90
90
|
- **insert-only**: Only processes SPAN_ENDED events, ignores updates
|
|
91
91
|
|
|
@@ -175,10 +175,13 @@ Failed flushes are retried with exponential backoff:
|
|
|
175
175
|
For `batch-with-updates` strategy:
|
|
176
176
|
|
|
177
177
|
- Tracks which spans have been created
|
|
178
|
-
-
|
|
178
|
+
- Holds updates/ends for spans this exporter started until their create is written
|
|
179
|
+
- Sends updates/ends for spans another process started straight to storage, and retries an end up to `maxRetries` times if it doesn't apply
|
|
179
180
|
- Logs warnings for out-of-order events
|
|
180
181
|
- Maintains sequence numbers for ordered updates
|
|
181
182
|
|
|
183
|
+
The default retries last about 7.5 seconds. Keep them longer than the `maxBatchWaitMs` of the process that started the span, or the end is dropped with `span-not-updatable`. `realtime` doesn't retry these ends and drops them right away. This retry needs a store with conditional span updates: libSQL, PostgreSQL, or the in-memory store. For the full behavior, see [Spans ended by another process](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage).
|
|
184
|
+
|
|
182
185
|
## Usage
|
|
183
186
|
|
|
184
187
|
```typescript
|
|
@@ -175,8 +175,8 @@ The exporter sets these standard OpenTelemetry attributes:
|
|
|
175
175
|
- `gen_ai.tool.name`: Tool identifier
|
|
176
176
|
- `gen_ai.tool.type`: `function`
|
|
177
177
|
- `gen_ai.tool.call.id`: Tool call ID
|
|
178
|
-
- `gen_ai.tool.
|
|
179
|
-
- `gen_ai.tool.
|
|
178
|
+
- `gen_ai.tool.call.arguments`: Tool input
|
|
179
|
+
- `gen_ai.tool.call.result`: Tool output
|
|
180
180
|
- `tool.success`: Success flag
|
|
181
181
|
|
|
182
182
|
**AGENT_RUN spans:**
|
|
@@ -42,12 +42,20 @@ export declare class EventBuffer {
|
|
|
42
42
|
reAddCreates(events: BufferedEvent[]): BufferedEvent[];
|
|
43
43
|
/** Re-add failed update events to the buffer, returning events that exceed max retries. */
|
|
44
44
|
reAddUpdates(events: BufferedEvent[]): BufferedEvent[];
|
|
45
|
+
/** Hold span ends storage didn't apply until their retry time, returning events that exceed max retries. */
|
|
46
|
+
holdForRetry(events: BufferedEvent[], retryDelay: (retryCount: number) => number): BufferedEvent[];
|
|
47
|
+
/** Move held ends whose retry time is at or before `until` into the update buffer. */
|
|
48
|
+
releaseHeldRetries(until?: number): void;
|
|
49
|
+
/** Remove and return every held end. */
|
|
50
|
+
takeHeldRetries(): BufferedEvent[];
|
|
51
|
+
/** Epoch milliseconds of the earliest held retry. */
|
|
52
|
+
get nextRetryAt(): number | undefined;
|
|
45
53
|
/** Alternate creates and eligible updates so either queue can make progress under load. */
|
|
46
54
|
takeByteBatch(maxRecords: number): {
|
|
47
55
|
creates: BufferedEvent[];
|
|
48
56
|
updates: BufferedEvent[];
|
|
49
57
|
};
|
|
50
|
-
/** Retries
|
|
58
|
+
/** Retries, deferred updates and held ends remain reserved; everything else has finished or been dropped. */
|
|
51
59
|
releaseByteBatch(events: BufferedEvent[]): void;
|
|
52
60
|
/** Snapshot of buffered create events. */
|
|
53
61
|
get creates(): BufferedEvent[];
|
|
@@ -72,6 +80,13 @@ export declare class EventBuffer {
|
|
|
72
80
|
spanExists(span: AnyExportedSpan): boolean;
|
|
73
81
|
/** Check whether this buffer saw the span's SPAN_STARTED but its create hasn't been confirmed yet. */
|
|
74
82
|
isAwaitingCreate(span: AnyExportedSpan): boolean;
|
|
83
|
+
/** Remember spans whose end storage accepted, forgetting the oldest once the set is full. */
|
|
84
|
+
rememberEndedSpans(spans: {
|
|
85
|
+
traceId: string;
|
|
86
|
+
spanId: string;
|
|
87
|
+
}[]): void;
|
|
88
|
+
/** Check whether storage accepted this span's end through this buffer. */
|
|
89
|
+
wasEnded(span: AnyExportedSpan): boolean;
|
|
75
90
|
/** Remove completed spans from tracking after their SPAN_ENDED updates are flushed. */
|
|
76
91
|
endFinishedSpans(args: {
|
|
77
92
|
records: UpdateSpanPartial[];
|