@mastra/otel-exporter 1.0.0-beta.8 → 1.0.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 +390 -0
- package/README.md +138 -66
- package/dist/index.cjs +73 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +72 -43
- package/dist/index.js.map +1 -1
- package/dist/tracing.d.ts +5 -0
- package/dist/tracing.d.ts.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -7
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` (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,15 @@ 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
|
+
```
|
|
169
240
|
|
|
170
241
|
```typescript
|
|
171
242
|
import { OtelExporter } from '@mastra/otel-exporter';
|
|
@@ -176,25 +247,26 @@ const mastra = new Mastra({
|
|
|
176
247
|
observability: {
|
|
177
248
|
configs: {
|
|
178
249
|
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
|
-
],
|
|
250
|
+
serviceName: 'my-service',
|
|
251
|
+
exporters: [new OtelExporter({ provider: { laminar: {} } })],
|
|
191
252
|
},
|
|
192
253
|
},
|
|
193
254
|
},
|
|
194
255
|
});
|
|
195
256
|
```
|
|
196
257
|
|
|
197
|
-
|
|
258
|
+
#### Explicit Configuration
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
new OtelExporter({
|
|
262
|
+
provider: {
|
|
263
|
+
laminar: {
|
|
264
|
+
apiKey: 'your-api-key',
|
|
265
|
+
endpoint: 'https://api.lmnr.ai/v1/traces', // Optional
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
```
|
|
198
270
|
|
|
199
271
|
### Zipkin
|
|
200
272
|
|
|
@@ -340,7 +412,7 @@ The OtelExporter uses OpenTelemetry's `BatchSpanProcessor` for efficient span ex
|
|
|
340
412
|
- **Default batch size**: 512 spans (configurable via `batchSize`)
|
|
341
413
|
- **Export interval**: Every 5 seconds or when batch is full
|
|
342
414
|
- **Queue size**: Up to 2048 spans queued in memory
|
|
343
|
-
- **
|
|
415
|
+
- **High-throughput support**: Handles large volumes of spans efficiently
|
|
344
416
|
|
|
345
417
|
This approach ensures:
|
|
346
418
|
|
package/dist/index.cjs
CHANGED
|
@@ -106,24 +106,31 @@ function resolveProviderConfig(config) {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
function resolveDash0Config(config) {
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
const apiKey = config.apiKey ?? process.env.DASH0_API_KEY;
|
|
110
|
+
const configEndpoint = config.endpoint ?? process.env.DASH0_ENDPOINT;
|
|
111
|
+
const dataset = config.dataset ?? process.env.DASH0_DATASET;
|
|
112
|
+
if (!apiKey) {
|
|
113
|
+
console.error(
|
|
114
|
+
"[OtelExporter] Dash0 configuration requires apiKey. Set DASH0_API_KEY environment variable or pass it in config. Tracing will be disabled."
|
|
115
|
+
);
|
|
111
116
|
return null;
|
|
112
117
|
}
|
|
113
|
-
if (!
|
|
114
|
-
console.error(
|
|
118
|
+
if (!configEndpoint) {
|
|
119
|
+
console.error(
|
|
120
|
+
"[OtelExporter] Dash0 configuration requires endpoint. Set DASH0_ENDPOINT environment variable or pass it in config. Tracing will be disabled."
|
|
121
|
+
);
|
|
115
122
|
return null;
|
|
116
123
|
}
|
|
117
|
-
let endpoint =
|
|
124
|
+
let endpoint = configEndpoint;
|
|
118
125
|
if (!endpoint.includes("/v1/traces")) {
|
|
119
126
|
endpoint = `${endpoint}/v1/traces`;
|
|
120
127
|
}
|
|
121
128
|
const headers = {
|
|
122
|
-
authorization: `Bearer ${
|
|
129
|
+
authorization: `Bearer ${apiKey}`
|
|
123
130
|
// lowercase for gRPC metadata
|
|
124
131
|
};
|
|
125
|
-
if (
|
|
126
|
-
headers["dash0-dataset"] =
|
|
132
|
+
if (dataset) {
|
|
133
|
+
headers["dash0-dataset"] = dataset;
|
|
127
134
|
}
|
|
128
135
|
return {
|
|
129
136
|
endpoint,
|
|
@@ -133,44 +140,58 @@ function resolveDash0Config(config) {
|
|
|
133
140
|
};
|
|
134
141
|
}
|
|
135
142
|
function resolveSignozConfig(config) {
|
|
136
|
-
|
|
137
|
-
|
|
143
|
+
const apiKey = config.apiKey ?? process.env.SIGNOZ_API_KEY;
|
|
144
|
+
const region = config.region ?? process.env.SIGNOZ_REGION;
|
|
145
|
+
const configEndpoint = config.endpoint ?? process.env.SIGNOZ_ENDPOINT;
|
|
146
|
+
if (!apiKey) {
|
|
147
|
+
console.error(
|
|
148
|
+
"[OtelExporter] SigNoz configuration requires apiKey. Set SIGNOZ_API_KEY environment variable or pass it in config. Tracing will be disabled."
|
|
149
|
+
);
|
|
138
150
|
return null;
|
|
139
151
|
}
|
|
140
|
-
const endpoint =
|
|
152
|
+
const endpoint = configEndpoint || `https://ingest.${region || "us"}.signoz.cloud:443/v1/traces`;
|
|
141
153
|
return {
|
|
142
154
|
endpoint,
|
|
143
155
|
headers: {
|
|
144
|
-
"signoz-ingestion-key":
|
|
156
|
+
"signoz-ingestion-key": apiKey
|
|
145
157
|
},
|
|
146
158
|
protocol: "http/protobuf"
|
|
147
159
|
};
|
|
148
160
|
}
|
|
149
161
|
function resolveNewRelicConfig(config) {
|
|
150
|
-
|
|
151
|
-
|
|
162
|
+
const apiKey = config.apiKey ?? process.env.NEW_RELIC_LICENSE_KEY;
|
|
163
|
+
const configEndpoint = config.endpoint ?? process.env.NEW_RELIC_ENDPOINT;
|
|
164
|
+
if (!apiKey) {
|
|
165
|
+
console.error(
|
|
166
|
+
"[OtelExporter] New Relic configuration requires apiKey (license key). Set NEW_RELIC_LICENSE_KEY environment variable or pass it in config. Tracing will be disabled."
|
|
167
|
+
);
|
|
152
168
|
return null;
|
|
153
169
|
}
|
|
154
|
-
const endpoint =
|
|
170
|
+
const endpoint = configEndpoint || "https://otlp.nr-data.net:443/v1/traces";
|
|
155
171
|
return {
|
|
156
172
|
endpoint,
|
|
157
173
|
headers: {
|
|
158
|
-
"api-key":
|
|
174
|
+
"api-key": apiKey
|
|
159
175
|
},
|
|
160
176
|
protocol: "http/protobuf"
|
|
161
177
|
};
|
|
162
178
|
}
|
|
163
179
|
function resolveTraceloopConfig(config) {
|
|
164
|
-
|
|
165
|
-
|
|
180
|
+
const apiKey = config.apiKey ?? process.env.TRACELOOP_API_KEY;
|
|
181
|
+
const destinationId = config.destinationId ?? process.env.TRACELOOP_DESTINATION_ID;
|
|
182
|
+
const configEndpoint = config.endpoint ?? process.env.TRACELOOP_ENDPOINT;
|
|
183
|
+
if (!apiKey) {
|
|
184
|
+
console.error(
|
|
185
|
+
"[OtelExporter] Traceloop configuration requires apiKey. Set TRACELOOP_API_KEY environment variable or pass it in config. Tracing will be disabled."
|
|
186
|
+
);
|
|
166
187
|
return null;
|
|
167
188
|
}
|
|
168
|
-
const endpoint =
|
|
189
|
+
const endpoint = configEndpoint || "https://api.traceloop.com/v1/traces";
|
|
169
190
|
const headers = {
|
|
170
|
-
Authorization: `Bearer ${
|
|
191
|
+
Authorization: `Bearer ${apiKey}`
|
|
171
192
|
};
|
|
172
|
-
if (
|
|
173
|
-
headers["x-traceloop-destination-id"] =
|
|
193
|
+
if (destinationId) {
|
|
194
|
+
headers["x-traceloop-destination-id"] = destinationId;
|
|
174
195
|
}
|
|
175
196
|
return {
|
|
176
197
|
endpoint,
|
|
@@ -179,17 +200,18 @@ function resolveTraceloopConfig(config) {
|
|
|
179
200
|
};
|
|
180
201
|
}
|
|
181
202
|
function resolveLaminarConfig(config) {
|
|
182
|
-
|
|
183
|
-
|
|
203
|
+
const apiKey = config.apiKey ?? process.env.LMNR_PROJECT_API_KEY;
|
|
204
|
+
const configEndpoint = config.endpoint ?? process.env.LAMINAR_ENDPOINT;
|
|
205
|
+
if (!apiKey) {
|
|
206
|
+
console.error(
|
|
207
|
+
"[OtelExporter] Laminar configuration requires apiKey. Set LMNR_PROJECT_API_KEY environment variable or pass it in config. Tracing will be disabled."
|
|
208
|
+
);
|
|
184
209
|
return null;
|
|
185
210
|
}
|
|
186
|
-
const endpoint =
|
|
211
|
+
const endpoint = configEndpoint || "https://api.lmnr.ai/v1/traces";
|
|
187
212
|
const headers = {
|
|
188
|
-
Authorization: `Bearer ${
|
|
213
|
+
Authorization: `Bearer ${apiKey}`
|
|
189
214
|
};
|
|
190
|
-
if (config.teamId) {
|
|
191
|
-
headers["x-laminar-team-id"] = config.teamId;
|
|
192
|
-
}
|
|
193
215
|
return {
|
|
194
216
|
endpoint,
|
|
195
217
|
headers,
|
|
@@ -334,10 +356,10 @@ function getSpanIdentifier(span) {
|
|
|
334
356
|
switch (span.type) {
|
|
335
357
|
case observability.SpanType.MODEL_GENERATION: {
|
|
336
358
|
const attrs = span.attributes;
|
|
337
|
-
return attrs?.model
|
|
359
|
+
return attrs?.model;
|
|
338
360
|
}
|
|
339
361
|
default:
|
|
340
|
-
return span.entityName ?? span.entityId
|
|
362
|
+
return span.entityName ?? span.entityId;
|
|
341
363
|
}
|
|
342
364
|
}
|
|
343
365
|
function getSpanName(span) {
|
|
@@ -701,16 +723,15 @@ var OtelExporter = class extends observability$1.BaseExporter {
|
|
|
701
723
|
async setupExporter() {
|
|
702
724
|
if (this.isSetup || this.exporter) return;
|
|
703
725
|
if (!this.config.provider) {
|
|
704
|
-
this.
|
|
726
|
+
this.setDisabled(
|
|
705
727
|
'[OtelExporter] Provider configuration is required. Use the "custom" provider for generic endpoints.'
|
|
706
728
|
);
|
|
707
|
-
this.isDisabled = true;
|
|
708
729
|
this.isSetup = true;
|
|
709
730
|
return;
|
|
710
731
|
}
|
|
711
732
|
const resolved = resolveProviderConfig(this.config.provider);
|
|
712
733
|
if (!resolved) {
|
|
713
|
-
this.
|
|
734
|
+
this.setDisabled("[OtelExporter] Provider configuration validation failed.");
|
|
714
735
|
this.isSetup = true;
|
|
715
736
|
return;
|
|
716
737
|
}
|
|
@@ -724,7 +745,7 @@ var OtelExporter = class extends observability$1.BaseExporter {
|
|
|
724
745
|
const providerName = Object.keys(this.config.provider)[0];
|
|
725
746
|
const ExporterClass = await loadExporter(protocol, providerName);
|
|
726
747
|
if (!ExporterClass) {
|
|
727
|
-
this.
|
|
748
|
+
this.setDisabled(`[OtelExporter] Exporter not available for protocol: ${protocol}`);
|
|
728
749
|
this.isSetup = true;
|
|
729
750
|
return;
|
|
730
751
|
}
|
|
@@ -743,13 +764,11 @@ var OtelExporter = class extends observability$1.BaseExporter {
|
|
|
743
764
|
metadata.set(key, value);
|
|
744
765
|
});
|
|
745
766
|
} catch (grpcError) {
|
|
746
|
-
this.
|
|
767
|
+
this.setDisabled(
|
|
747
768
|
`[OtelExporter] Failed to load gRPC metadata. Install required packages:
|
|
748
|
-
npm install @opentelemetry/exporter-trace-otlp-grpc @grpc/grpc-js
|
|
749
|
-
`,
|
|
750
|
-
grpcError
|
|
769
|
+
npm install @opentelemetry/exporter-trace-otlp-grpc @grpc/grpc-js`
|
|
751
770
|
);
|
|
752
|
-
this.
|
|
771
|
+
this.logger.error("[OtelExporter] gRPC error details:", grpcError);
|
|
753
772
|
this.isSetup = true;
|
|
754
773
|
return;
|
|
755
774
|
}
|
|
@@ -766,8 +785,8 @@ var OtelExporter = class extends observability$1.BaseExporter {
|
|
|
766
785
|
});
|
|
767
786
|
}
|
|
768
787
|
} catch (error) {
|
|
769
|
-
this.
|
|
770
|
-
this.
|
|
788
|
+
this.setDisabled("[OtelExporter] Failed to create exporter.");
|
|
789
|
+
this.logger.error("[OtelExporter] Exporter creation error details:", error);
|
|
771
790
|
this.isSetup = true;
|
|
772
791
|
return;
|
|
773
792
|
}
|
|
@@ -827,6 +846,16 @@ var OtelExporter = class extends observability$1.BaseExporter {
|
|
|
827
846
|
this.logger.error(`[OtelExporter] Failed to export span ${span.id}:`, error);
|
|
828
847
|
}
|
|
829
848
|
}
|
|
849
|
+
/**
|
|
850
|
+
* Force flush any buffered spans without shutting down the exporter.
|
|
851
|
+
* Delegates to the BatchSpanProcessor's forceFlush() method.
|
|
852
|
+
*/
|
|
853
|
+
async flush() {
|
|
854
|
+
if (this.processor) {
|
|
855
|
+
await this.processor.forceFlush();
|
|
856
|
+
this.logger.debug("[OtelExporter] Flushed pending spans");
|
|
857
|
+
}
|
|
858
|
+
}
|
|
830
859
|
async shutdown() {
|
|
831
860
|
if (this.processor) {
|
|
832
861
|
await this.processor.shutdown();
|
|
@@ -836,6 +865,8 @@ var OtelExporter = class extends observability$1.BaseExporter {
|
|
|
836
865
|
|
|
837
866
|
exports.OtelExporter = OtelExporter;
|
|
838
867
|
exports.SpanConverter = SpanConverter;
|
|
868
|
+
exports.getAttributes = getAttributes;
|
|
839
869
|
exports.getSpanKind = getSpanKind;
|
|
870
|
+
exports.getSpanName = getSpanName;
|
|
840
871
|
//# sourceMappingURL=index.cjs.map
|
|
841
872
|
//# sourceMappingURL=index.cjs.map
|