@mastra/otel-exporter 0.0.0-main-test-2-20251127211532 → 0.0.0-mastra-auto-detect-server-20260108233416
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 +332 -12
- package/README.md +188 -68
- package/dist/gen-ai-messages.d.ts +26 -0
- package/dist/gen-ai-messages.d.ts.map +1 -0
- package/dist/gen-ai-semantics.d.ts +40 -0
- package/dist/gen-ai-semantics.d.ts.map +1 -0
- package/dist/index.cjs +491 -391
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +493 -392
- package/dist/index.js.map +1 -1
- package/dist/span-converter.d.ts +26 -35
- package/dist/span-converter.d.ts.map +1 -1
- package/dist/tracing.d.ts +2 -2
- package/dist/tracing.d.ts.map +1 -1
- package/package.json +9 -10
- package/dist/mastra-span.d.ts +0 -38
- package/dist/mastra-span.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -4,6 +4,18 @@ Export Mastra traces to any OpenTelemetry-compatible observability platform.
|
|
|
4
4
|
|
|
5
5
|
> **⚠️ Important:** This package requires you to install an additional exporter package based on your provider. Each provider section below includes the specific installation command.
|
|
6
6
|
|
|
7
|
+
## Environment Variables
|
|
8
|
+
|
|
9
|
+
All providers support zero-config setup via environment variables. Set the appropriate variables and the exporter will automatically use them:
|
|
10
|
+
|
|
11
|
+
| Provider | Environment Variables |
|
|
12
|
+
| --------- | ------------------------------------------------------------------------------------------- |
|
|
13
|
+
| Dash0 | `DASH0_API_KEY` (required), `DASH0_ENDPOINT` (required), `DASH0_DATASET` (optional) |
|
|
14
|
+
| SigNoz | `SIGNOZ_API_KEY` (required), `SIGNOZ_REGION` (optional), `SIGNOZ_ENDPOINT` (optional) |
|
|
15
|
+
| New Relic | `NEW_RELIC_LICENSE_KEY` (required), `NEW_RELIC_ENDPOINT` (optional) |
|
|
16
|
+
| Traceloop | `TRACELOOP_API_KEY` (required), `TRACELOOP_DESTINATION_ID`, `TRACELOOP_ENDPOINT` (optional) |
|
|
17
|
+
| Laminar | `LMNR_PROJECT_API_KEY` (required), `LAMINAR_ENDPOINT`, `LAMINAR_TEAM_ID` (optional) |
|
|
18
|
+
|
|
7
19
|
## Supported Providers
|
|
8
20
|
|
|
9
21
|
### Dash0
|
|
@@ -15,7 +27,16 @@ Export Mastra traces to any OpenTelemetry-compatible observability platform.
|
|
|
15
27
|
npm install @mastra/otel-exporter @opentelemetry/exporter-trace-otlp-grpc @grpc/grpc-js
|
|
16
28
|
```
|
|
17
29
|
|
|
18
|
-
####
|
|
30
|
+
#### Zero-Config Setup
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Required
|
|
34
|
+
DASH0_API_KEY=your-api-key
|
|
35
|
+
DASH0_ENDPOINT=ingress.us-west-2.aws.dash0.com:4317
|
|
36
|
+
|
|
37
|
+
# Optional
|
|
38
|
+
DASH0_DATASET=production
|
|
39
|
+
```
|
|
19
40
|
|
|
20
41
|
```typescript
|
|
21
42
|
import { OtelExporter } from '@mastra/otel-exporter';
|
|
@@ -26,24 +47,28 @@ const mastra = new Mastra({
|
|
|
26
47
|
observability: {
|
|
27
48
|
configs: {
|
|
28
49
|
otel: {
|
|
29
|
-
serviceName: '
|
|
30
|
-
exporters: [
|
|
31
|
-
new OtelExporter({
|
|
32
|
-
provider: {
|
|
33
|
-
dash0: {
|
|
34
|
-
apiKey: process.env.DASH0_API_KEY, // Required at runtime
|
|
35
|
-
endpoint: 'ingress.us-west-2.aws.dash0.com:4317', // Required at runtime
|
|
36
|
-
dataset: 'production', // Optional: dataset name
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
})
|
|
40
|
-
],
|
|
50
|
+
serviceName: 'my-service',
|
|
51
|
+
exporters: [new OtelExporter({ provider: { dash0: {} } })],
|
|
41
52
|
},
|
|
42
53
|
},
|
|
43
54
|
},
|
|
44
55
|
});
|
|
45
56
|
```
|
|
46
57
|
|
|
58
|
+
#### Explicit Configuration
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
new OtelExporter({
|
|
62
|
+
provider: {
|
|
63
|
+
dash0: {
|
|
64
|
+
apiKey: 'your-api-key',
|
|
65
|
+
endpoint: 'ingress.us-west-2.aws.dash0.com:4317',
|
|
66
|
+
dataset: 'production', // Optional
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
47
72
|
**Note:** Get your endpoint from your Dash0 dashboard. It should be in the format `ingress.{region}.aws.dash0.com:4317`.
|
|
48
73
|
|
|
49
74
|
### SigNoz
|
|
@@ -54,7 +79,16 @@ const mastra = new Mastra({
|
|
|
54
79
|
npm install @mastra/otel-exporter @opentelemetry/exporter-trace-otlp-proto
|
|
55
80
|
```
|
|
56
81
|
|
|
57
|
-
####
|
|
82
|
+
#### Zero-Config Setup
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Required
|
|
86
|
+
SIGNOZ_API_KEY=your-api-key
|
|
87
|
+
|
|
88
|
+
# Optional
|
|
89
|
+
SIGNOZ_REGION=us # 'us' | 'eu' | 'in'
|
|
90
|
+
SIGNOZ_ENDPOINT=https://my-signoz.example.com # For self-hosted
|
|
91
|
+
```
|
|
58
92
|
|
|
59
93
|
```typescript
|
|
60
94
|
import { OtelExporter } from '@mastra/otel-exporter';
|
|
@@ -65,24 +99,28 @@ const mastra = new Mastra({
|
|
|
65
99
|
observability: {
|
|
66
100
|
configs: {
|
|
67
101
|
otel: {
|
|
68
|
-
serviceName: '
|
|
69
|
-
exporters: [
|
|
70
|
-
new OtelExporter({
|
|
71
|
-
provider: {
|
|
72
|
-
signoz: {
|
|
73
|
-
apiKey: process.env.SIGNOZ_API_KEY, // Required at runtime
|
|
74
|
-
region: 'us', // Optional: 'us' | 'eu' | 'in', defaults to 'us'
|
|
75
|
-
// endpoint: 'https://my-signoz.example.com', // Optional: for self-hosted
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
})
|
|
79
|
-
],
|
|
102
|
+
serviceName: 'my-service',
|
|
103
|
+
exporters: [new OtelExporter({ provider: { signoz: {} } })],
|
|
80
104
|
},
|
|
81
105
|
},
|
|
82
106
|
},
|
|
83
107
|
});
|
|
84
108
|
```
|
|
85
109
|
|
|
110
|
+
#### Explicit Configuration
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
new OtelExporter({
|
|
114
|
+
provider: {
|
|
115
|
+
signoz: {
|
|
116
|
+
apiKey: 'your-api-key',
|
|
117
|
+
region: 'us', // Optional: 'us' | 'eu' | 'in'
|
|
118
|
+
endpoint: 'https://my-signoz.example.com', // Optional: for self-hosted
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
86
124
|
### New Relic
|
|
87
125
|
|
|
88
126
|
#### Installation
|
|
@@ -91,7 +129,15 @@ const mastra = new Mastra({
|
|
|
91
129
|
npm install @mastra/otel-exporter @opentelemetry/exporter-trace-otlp-proto
|
|
92
130
|
```
|
|
93
131
|
|
|
94
|
-
####
|
|
132
|
+
#### Zero-Config Setup
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Required
|
|
136
|
+
NEW_RELIC_LICENSE_KEY=your-license-key
|
|
137
|
+
|
|
138
|
+
# Optional
|
|
139
|
+
NEW_RELIC_ENDPOINT=https://otlp.eu01.nr-data.net # For EU region
|
|
140
|
+
```
|
|
95
141
|
|
|
96
142
|
```typescript
|
|
97
143
|
import { OtelExporter } from '@mastra/otel-exporter';
|
|
@@ -102,23 +148,27 @@ const mastra = new Mastra({
|
|
|
102
148
|
observability: {
|
|
103
149
|
configs: {
|
|
104
150
|
otel: {
|
|
105
|
-
serviceName: '
|
|
106
|
-
exporters: [
|
|
107
|
-
new OtelExporter({
|
|
108
|
-
provider: {
|
|
109
|
-
newrelic: {
|
|
110
|
-
apiKey: process.env.NEW_RELIC_LICENSE_KEY, // Required at runtime
|
|
111
|
-
// endpoint: 'https://otlp.eu01.nr-data.net', // Optional: for EU region
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
})
|
|
115
|
-
],
|
|
151
|
+
serviceName: 'my-service',
|
|
152
|
+
exporters: [new OtelExporter({ provider: { newrelic: {} } })],
|
|
116
153
|
},
|
|
117
154
|
},
|
|
118
155
|
},
|
|
119
156
|
});
|
|
120
157
|
```
|
|
121
158
|
|
|
159
|
+
#### Explicit Configuration
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
new OtelExporter({
|
|
163
|
+
provider: {
|
|
164
|
+
newrelic: {
|
|
165
|
+
apiKey: 'your-license-key',
|
|
166
|
+
endpoint: 'https://otlp.eu01.nr-data.net', // Optional: for EU region
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
|
|
122
172
|
### Traceloop
|
|
123
173
|
|
|
124
174
|
#### Installation
|
|
@@ -128,7 +178,16 @@ const mastra = new Mastra({
|
|
|
128
178
|
npm install @mastra/otel-exporter @opentelemetry/exporter-trace-otlp-http
|
|
129
179
|
```
|
|
130
180
|
|
|
131
|
-
####
|
|
181
|
+
#### Zero-Config Setup
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# Required
|
|
185
|
+
TRACELOOP_API_KEY=your-api-key
|
|
186
|
+
|
|
187
|
+
# Optional
|
|
188
|
+
TRACELOOP_DESTINATION_ID=my-destination
|
|
189
|
+
TRACELOOP_ENDPOINT=https://custom.traceloop.com
|
|
190
|
+
```
|
|
132
191
|
|
|
133
192
|
```typescript
|
|
134
193
|
import { OtelExporter } from '@mastra/otel-exporter';
|
|
@@ -139,24 +198,28 @@ const mastra = new Mastra({
|
|
|
139
198
|
observability: {
|
|
140
199
|
configs: {
|
|
141
200
|
otel: {
|
|
142
|
-
serviceName: '
|
|
143
|
-
exporters: [
|
|
144
|
-
new OtelExporter({
|
|
145
|
-
provider: {
|
|
146
|
-
traceloop: {
|
|
147
|
-
apiKey: process.env.TRACELOOP_API_KEY, // Required at runtime
|
|
148
|
-
destinationId: 'my-destination', // Optional
|
|
149
|
-
// endpoint: 'https://custom.traceloop.com', // Optional
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
})
|
|
153
|
-
],
|
|
201
|
+
serviceName: 'my-service',
|
|
202
|
+
exporters: [new OtelExporter({ provider: { traceloop: {} } })],
|
|
154
203
|
},
|
|
155
204
|
},
|
|
156
205
|
},
|
|
157
206
|
});
|
|
158
207
|
```
|
|
159
208
|
|
|
209
|
+
#### Explicit Configuration
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
new OtelExporter({
|
|
213
|
+
provider: {
|
|
214
|
+
traceloop: {
|
|
215
|
+
apiKey: 'your-api-key',
|
|
216
|
+
destinationId: 'my-destination', // Optional
|
|
217
|
+
endpoint: 'https://custom.traceloop.com', // Optional
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
160
223
|
### Laminar
|
|
161
224
|
|
|
162
225
|
#### Installation
|
|
@@ -165,7 +228,16 @@ const mastra = new Mastra({
|
|
|
165
228
|
npm install @mastra/otel-exporter @opentelemetry/exporter-trace-otlp-proto
|
|
166
229
|
```
|
|
167
230
|
|
|
168
|
-
####
|
|
231
|
+
#### Zero-Config Setup
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
# Required
|
|
235
|
+
LMNR_PROJECT_API_KEY=your-api-key
|
|
236
|
+
|
|
237
|
+
# Optional
|
|
238
|
+
LAMINAR_ENDPOINT=https://api.lmnr.ai/v1/traces
|
|
239
|
+
LAMINAR_TEAM_ID=your-team-id # For backwards compatibility
|
|
240
|
+
```
|
|
169
241
|
|
|
170
242
|
```typescript
|
|
171
243
|
import { OtelExporter } from '@mastra/otel-exporter';
|
|
@@ -176,24 +248,28 @@ const mastra = new Mastra({
|
|
|
176
248
|
observability: {
|
|
177
249
|
configs: {
|
|
178
250
|
otel: {
|
|
179
|
-
serviceName: '
|
|
180
|
-
exporters: [
|
|
181
|
-
new OtelExporter({
|
|
182
|
-
provider: {
|
|
183
|
-
laminar: {
|
|
184
|
-
apiKey: process.env.LMNR_PROJECT_API_KEY, // Required at runtime
|
|
185
|
-
// teamId: process.env.LAMINAR_TEAM_ID, // Optional, for backwards compatibility
|
|
186
|
-
// endpoint: 'https://api.lmnr.ai/v1/traces', // Optional
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
})
|
|
190
|
-
],
|
|
251
|
+
serviceName: 'my-service',
|
|
252
|
+
exporters: [new OtelExporter({ provider: { laminar: {} } })],
|
|
191
253
|
},
|
|
192
254
|
},
|
|
193
255
|
},
|
|
194
256
|
});
|
|
195
257
|
```
|
|
196
258
|
|
|
259
|
+
#### Explicit Configuration
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
new OtelExporter({
|
|
263
|
+
provider: {
|
|
264
|
+
laminar: {
|
|
265
|
+
apiKey: 'your-api-key',
|
|
266
|
+
teamId: 'your-team-id', // Optional, for backwards compatibility
|
|
267
|
+
endpoint: 'https://api.lmnr.ai/v1/traces', // Optional
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
```
|
|
272
|
+
|
|
197
273
|
**Note:** Laminar now only requires the `LMNR_PROJECT_API_KEY`. The `teamId` is optional.
|
|
198
274
|
|
|
199
275
|
### Zipkin
|
|
@@ -340,7 +416,7 @@ The OtelExporter uses OpenTelemetry's `BatchSpanProcessor` for efficient span ex
|
|
|
340
416
|
- **Default batch size**: 512 spans (configurable via `batchSize`)
|
|
341
417
|
- **Export interval**: Every 5 seconds or when batch is full
|
|
342
418
|
- **Queue size**: Up to 2048 spans queued in memory
|
|
343
|
-
- **
|
|
419
|
+
- **High-throughput support**: Handles large volumes of spans efficiently
|
|
344
420
|
|
|
345
421
|
This approach ensures:
|
|
346
422
|
|
|
@@ -359,7 +435,7 @@ Spans are named following OTEL conventions:
|
|
|
359
435
|
|
|
360
436
|
- **LLM Operations**: `chat {model}` or `tool_selection {model}`
|
|
361
437
|
- **Tool Execution**: `tool.execute {tool_name}`
|
|
362
|
-
- **Agent Runs**: `
|
|
438
|
+
- **Agent Runs**: `invoke_agent {agent_name}`
|
|
363
439
|
- **Workflow Runs**: `workflow.{workflow_id}`
|
|
364
440
|
|
|
365
441
|
### Attributes
|
|
@@ -369,7 +445,7 @@ The exporter maps Mastra's tracing data to OTEL-compliant attributes:
|
|
|
369
445
|
#### Core Attributes
|
|
370
446
|
|
|
371
447
|
- `gen_ai.operation.name` - Operation type (chat, tool.execute, agent.run, workflow.run)
|
|
372
|
-
- `gen_ai.
|
|
448
|
+
- `gen_ai.provider.name` - AI provider (openai, anthropic, etc.)
|
|
373
449
|
- `gen_ai.request.model` - Model identifier
|
|
374
450
|
|
|
375
451
|
#### LLM-Specific Attributes
|
|
@@ -382,8 +458,12 @@ The exporter maps Mastra's tracing data to OTEL-compliant attributes:
|
|
|
382
458
|
- `gen_ai.request.top_p` - Top-p sampling parameter
|
|
383
459
|
- `gen_ai.request.top_k` - Top-k sampling parameter
|
|
384
460
|
- `gen_ai.response.finish_reasons` - Reason for completion
|
|
461
|
+
- `gen_ai.response.model` - Actual model used in response (may differ from request)
|
|
462
|
+
- `gen_ai.response.id` - Unique response identifier
|
|
385
463
|
- `gen_ai.prompt` - Input prompt (for Model spans)
|
|
386
464
|
- `gen_ai.completion` - Model output (for Model spans)
|
|
465
|
+
- `server.address` - Server address for the model endpoint
|
|
466
|
+
- `server.port` - Server port for the model endpoint
|
|
387
467
|
|
|
388
468
|
#### Tool Attributes
|
|
389
469
|
|
|
@@ -395,7 +475,10 @@ The exporter maps Mastra's tracing data to OTEL-compliant attributes:
|
|
|
395
475
|
|
|
396
476
|
#### Agent & Workflow Attributes
|
|
397
477
|
|
|
398
|
-
- `agent.id` - Agent identifier
|
|
478
|
+
- `gen_ai.agent.id` - Agent identifier
|
|
479
|
+
- `gen_ai.agent.name` - Human-readable agent name
|
|
480
|
+
- `gen_ai.conversation.id` - Conversation/thread/session identifier
|
|
481
|
+
- `agent.id` - Agent identifier (also included for compatibility)
|
|
399
482
|
- `agent.max_steps` - Maximum agent steps
|
|
400
483
|
- `workflow.id` - Workflow identifier
|
|
401
484
|
- `workflow.status` - Workflow execution status
|
|
@@ -407,6 +490,43 @@ The exporter maps Mastra's tracing data to OTEL-compliant attributes:
|
|
|
407
490
|
- `error.message` - Error description
|
|
408
491
|
- `error.domain` - Error domain/category
|
|
409
492
|
|
|
493
|
+
### Opt-In Content Attributes
|
|
494
|
+
|
|
495
|
+
For enhanced observability, you can enable additional content attributes that capture detailed message data. These attributes may contain sensitive information and should only be enabled with proper consent and security considerations.
|
|
496
|
+
|
|
497
|
+
To enable content attributes:
|
|
498
|
+
|
|
499
|
+
```typescript
|
|
500
|
+
new OtelExporter({
|
|
501
|
+
provider: {
|
|
502
|
+
/* your provider config */
|
|
503
|
+
},
|
|
504
|
+
genAiConventions: {
|
|
505
|
+
includeContentAttributes: true, // Default: false
|
|
506
|
+
},
|
|
507
|
+
});
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
When enabled, the following additional attributes are captured:
|
|
511
|
+
|
|
512
|
+
#### Model Content Attributes
|
|
513
|
+
|
|
514
|
+
- `gen_ai.input.messages` - Structured input messages in OpenTelemetry format
|
|
515
|
+
- `gen_ai.output.messages` - Structured output messages in OpenTelemetry format
|
|
516
|
+
|
|
517
|
+
These attributes convert Mastra's message format to the OpenTelemetry GenAI standard message schema, providing detailed conversation history and tool interactions.
|
|
518
|
+
|
|
519
|
+
#### Agent Content Attributes
|
|
520
|
+
|
|
521
|
+
- `gen_ai.system_instructions` - Agent system instructions/prompts
|
|
522
|
+
|
|
523
|
+
**Privacy Considerations:**
|
|
524
|
+
|
|
525
|
+
- These attributes may contain user data, prompts, and model responses
|
|
526
|
+
- Only enable in environments where data privacy and compliance requirements are met
|
|
527
|
+
- Consider using span processors to filter sensitive data before export
|
|
528
|
+
- Review your organization's data retention and privacy policies before enabling
|
|
529
|
+
|
|
410
530
|
## Troubleshooting
|
|
411
531
|
|
|
412
532
|
### Missing Dependency Error
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for converting Mastra messages to OpenTelemetry gen_ai message format
|
|
3
|
+
* Based on OpenTelemetry GenAI semantic conventions
|
|
4
|
+
* @see https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/#gen-ai-input-messages
|
|
5
|
+
* @see https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-input-messages.json
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Convert an Input/Output string from a MastraSpan into a jsonified string that adheres to
|
|
9
|
+
* OpenTelemetry gen_ai.input.messages and gen_ai.output.messages schema.
|
|
10
|
+
* If parsing fails at any step, the original inputOutputString is returned unmodified.
|
|
11
|
+
*
|
|
12
|
+
* This conversion is best effort; It assumes a consistent shape for mastra messages, and converts
|
|
13
|
+
* into the gen_ai input and output schemas as of October 20th, 2025.
|
|
14
|
+
*
|
|
15
|
+
* @see https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/#gen-ai-input-messages
|
|
16
|
+
* @see https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-input-messages.json
|
|
17
|
+
* @see https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/#gen-ai-output-messages
|
|
18
|
+
* @see https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-output-messages.json
|
|
19
|
+
*
|
|
20
|
+
* @param inputOutputString a jsonified string that contains messages adhering to what appears to be
|
|
21
|
+
* Mastra's message shape.
|
|
22
|
+
* @returns a jsonified string that contains messages adhering to the OpenTelemetry gen_ai.input.messages and gen_ai.output.messages schema.
|
|
23
|
+
* If parsing fails at any step, the original inputOutputString is returned unmodified.
|
|
24
|
+
*/
|
|
25
|
+
export declare const convertMastraMessagesToGenAIMessages: (inputOutputString: string) => string;
|
|
26
|
+
//# sourceMappingURL=gen-ai-messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gen-ai-messages.d.ts","sourceRoot":"","sources":["../src/gen-ai-messages.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,oCAAoC,GAAI,mBAAmB,MAAM,KAAG,MAyEhF,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for converting Mastra Spans to OTel Spans
|
|
3
|
+
* with Semantic conventions for generative AI systems
|
|
4
|
+
* @see https://github.com/open-telemetry/semantic-conventions/blob/v1.38.0/docs/gen-ai/README.md
|
|
5
|
+
* @see https://github.com/open-telemetry/semantic-conventions/blob/v1.38.0/docs/gen-ai/gen-ai-events.md
|
|
6
|
+
* @see https://github.com/open-telemetry/semantic-conventions/blob/v1.38.0/docs/gen-ai/gen-ai-spans.md
|
|
7
|
+
* @see https://github.com/open-telemetry/semantic-conventions/blob/v1.38.0/docs/gen-ai/gen-ai-agent-spans.md
|
|
8
|
+
* @see https://opentelemetry.io/docs/specs/semconv/gen-ai/non-normative/examples-llm-calls/
|
|
9
|
+
* @see https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/
|
|
10
|
+
*/
|
|
11
|
+
import type { AnyExportedSpan, UsageStats } from '@mastra/core/observability';
|
|
12
|
+
import type { Attributes } from '@opentelemetry/api';
|
|
13
|
+
import { ATTR_GEN_AI_USAGE_INPUT_TOKENS, ATTR_GEN_AI_USAGE_OUTPUT_TOKENS } from '@opentelemetry/semantic-conventions/incubating';
|
|
14
|
+
/**
|
|
15
|
+
* Token usage attributes following OTel GenAI semantic conventions.
|
|
16
|
+
* @see https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/
|
|
17
|
+
*/
|
|
18
|
+
export interface OtelUsageMetrics {
|
|
19
|
+
[ATTR_GEN_AI_USAGE_INPUT_TOKENS]?: number;
|
|
20
|
+
[ATTR_GEN_AI_USAGE_OUTPUT_TOKENS]?: number;
|
|
21
|
+
'gen_ai.usage.reasoning_tokens'?: number;
|
|
22
|
+
'gen_ai.usage.cached_input_tokens'?: number;
|
|
23
|
+
'gen_ai.usage.cache_write_tokens'?: number;
|
|
24
|
+
'gen_ai.usage.audio_input_tokens'?: number;
|
|
25
|
+
'gen_ai.usage.audio_output_tokens'?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Formats UsageStats to OTel GenAI semantic convention attributes.
|
|
29
|
+
*/
|
|
30
|
+
export declare function formatUsageMetrics(usage?: UsageStats): OtelUsageMetrics;
|
|
31
|
+
/**
|
|
32
|
+
* Get an OTEL-compliant span name based on span type and attributes
|
|
33
|
+
*/
|
|
34
|
+
export declare function getSpanName(span: AnyExportedSpan): string;
|
|
35
|
+
/**
|
|
36
|
+
* Gets OpenTelemetry attributes from Mastra Span
|
|
37
|
+
* Following OTEL Semantic Conventions for GenAI
|
|
38
|
+
*/
|
|
39
|
+
export declare function getAttributes(span: AnyExportedSpan): Attributes;
|
|
40
|
+
//# sourceMappingURL=gen-ai-semantics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gen-ai-semantics.d.ts","sourceRoot":"","sources":["../src/gen-ai-semantics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAEV,eAAe,EAIf,UAAU,EACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAgBL,8BAA8B,EAC9B,+BAA+B,EAYhC,MAAM,gDAAgD,CAAC;AAGxD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,CAAC,8BAA8B,CAAC,CAAC,EAAE,MAAM,CAAC;IAC1C,CAAC,+BAA+B,CAAC,CAAC,EAAE,MAAM,CAAC;IAC3C,+BAA+B,CAAC,EAAE,MAAM,CAAC;IACzC,kCAAkC,CAAC,EAAE,MAAM,CAAC;IAC5C,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,kCAAkC,CAAC,EAAE,MAAM,CAAC;CAC7C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,gBAAgB,CAqCvE;AAuCD;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAUzD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,UAAU,CA+K/D"}
|