@mastra/duckdb 1.1.0-alpha.1 → 1.1.0-alpha.2
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 +13 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{observability-W2QRBK56.cjs → observability-AMG7NSKE.cjs} +371 -62
- package/dist/observability-AMG7NSKE.cjs.map +1 -0
- package/dist/{observability-PW6J27KS.js → observability-X7G4VJKT.js} +371 -62
- package/dist/observability-X7G4VJKT.js.map +1 -0
- package/dist/storage/domains/observability/ddl.d.ts +7 -5
- package/dist/storage/domains/observability/ddl.d.ts.map +1 -1
- package/dist/storage/domains/observability/feedback.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/scores.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/observability-PW6J27KS.js.map +0 -1
- package/dist/observability-W2QRBK56.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @mastra/duckdb
|
|
2
2
|
|
|
3
|
+
## 1.1.0-alpha.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Updated DuckDB observability storage to support the current Mastra observability fields for logs, metrics, scores, and feedback. ([#14851](https://github.com/mastra-ai/mastra/pull/14851))
|
|
8
|
+
|
|
9
|
+
Scores and feedback stored in DuckDB now include the new correlation data used across Mastra observability.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`fbf22a7`](https://github.com/mastra-ai/mastra/commit/fbf22a7ad86bcb50dcf30459f0d075e51ddeb468), [`04160ee`](https://github.com/mastra-ai/mastra/commit/04160eedf3130003cf842ad08428c8ff69af4cc1), [`2c27503`](https://github.com/mastra-ai/mastra/commit/2c275032510d131d2cde47f99953abf0fe02c081), [`424a1df`](https://github.com/mastra-ai/mastra/commit/424a1df7bee59abb5c83717a54807fdd674a6224), [`12c88a6`](https://github.com/mastra-ai/mastra/commit/12c88a6e32bf982c2fe0c6af62e65a3414519a75), [`43595bf`](https://github.com/mastra-ai/mastra/commit/43595bf7b8df1a6edce7a23b445b5124d2a0b473), [`78670e9`](https://github.com/mastra-ai/mastra/commit/78670e97e76d7422cf7025faf371b2aeafed860d), [`d400e7c`](https://github.com/mastra-ai/mastra/commit/d400e7c8b8d7afa6ba2c71769eace4048e3cef8e), [`f58d1a7`](https://github.com/mastra-ai/mastra/commit/f58d1a7a457588a996c3ecb53201a68f3d28c432), [`a49a929`](https://github.com/mastra-ai/mastra/commit/a49a92904968b4fc67e01effee8c7c8d0464ba85)]:
|
|
14
|
+
- @mastra/core@1.18.0-alpha.4
|
|
15
|
+
|
|
3
16
|
## 1.1.0-alpha.1
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -583,7 +583,7 @@ var ObservabilityStorageDuckDB = class extends storage.ObservabilityStorage {
|
|
|
583
583
|
return null;
|
|
584
584
|
}
|
|
585
585
|
if (!this.loadPromise) {
|
|
586
|
-
this.loadPromise = import('./observability-
|
|
586
|
+
this.loadPromise = import('./observability-AMG7NSKE.cjs').then(({ ObservabilityStorageDuckDB: ObservabilityStorageDuckDB2 }) => {
|
|
587
587
|
const delegate = new ObservabilityStorageDuckDB2({ db: this.db });
|
|
588
588
|
this.delegate = delegate;
|
|
589
589
|
return delegate;
|
package/dist/index.js
CHANGED
|
@@ -582,7 +582,7 @@ var ObservabilityStorageDuckDB = class extends ObservabilityStorage {
|
|
|
582
582
|
return null;
|
|
583
583
|
}
|
|
584
584
|
if (!this.loadPromise) {
|
|
585
|
-
this.loadPromise = import('./observability-
|
|
585
|
+
this.loadPromise = import('./observability-X7G4VJKT.js').then(({ ObservabilityStorageDuckDB: ObservabilityStorageDuckDB2 }) => {
|
|
586
586
|
const delegate = new ObservabilityStorageDuckDB2({ db: this.db });
|
|
587
587
|
this.delegate = delegate;
|
|
588
588
|
return delegate;
|
|
@@ -82,7 +82,7 @@ CREATE TABLE IF NOT EXISTS metric_events (
|
|
|
82
82
|
threadId VARCHAR,
|
|
83
83
|
requestId VARCHAR,
|
|
84
84
|
environment VARCHAR,
|
|
85
|
-
|
|
85
|
+
executionSource VARCHAR,
|
|
86
86
|
serviceName VARCHAR,
|
|
87
87
|
|
|
88
88
|
-- Metric-specific scalars
|
|
@@ -130,7 +130,7 @@ CREATE TABLE IF NOT EXISTS log_events (
|
|
|
130
130
|
threadId VARCHAR,
|
|
131
131
|
requestId VARCHAR,
|
|
132
132
|
environment VARCHAR,
|
|
133
|
-
|
|
133
|
+
executionSource VARCHAR,
|
|
134
134
|
serviceName VARCHAR,
|
|
135
135
|
|
|
136
136
|
-- Log-specific scalars
|
|
@@ -154,15 +154,41 @@ CREATE TABLE IF NOT EXISTS score_events (
|
|
|
154
154
|
experimentId VARCHAR,
|
|
155
155
|
scoreTraceId VARCHAR,
|
|
156
156
|
|
|
157
|
+
-- Entity hierarchy
|
|
158
|
+
entityType VARCHAR,
|
|
159
|
+
entityId VARCHAR,
|
|
160
|
+
entityName VARCHAR,
|
|
161
|
+
parentEntityType VARCHAR,
|
|
162
|
+
parentEntityId VARCHAR,
|
|
163
|
+
parentEntityName VARCHAR,
|
|
164
|
+
rootEntityType VARCHAR,
|
|
165
|
+
rootEntityId VARCHAR,
|
|
166
|
+
rootEntityName VARCHAR,
|
|
167
|
+
|
|
168
|
+
-- Context
|
|
169
|
+
userId VARCHAR,
|
|
170
|
+
organizationId VARCHAR,
|
|
171
|
+
resourceId VARCHAR,
|
|
172
|
+
runId VARCHAR,
|
|
173
|
+
sessionId VARCHAR,
|
|
174
|
+
threadId VARCHAR,
|
|
175
|
+
requestId VARCHAR,
|
|
176
|
+
environment VARCHAR,
|
|
177
|
+
executionSource VARCHAR,
|
|
178
|
+
serviceName VARCHAR,
|
|
179
|
+
|
|
157
180
|
-- Score-specific scalars
|
|
158
181
|
scorerId VARCHAR NOT NULL,
|
|
159
182
|
scorerVersion VARCHAR,
|
|
160
183
|
source VARCHAR,
|
|
184
|
+
scoreSource VARCHAR,
|
|
161
185
|
score DOUBLE NOT NULL,
|
|
162
186
|
reason VARCHAR,
|
|
163
187
|
|
|
164
188
|
-- JSON fields
|
|
165
|
-
|
|
189
|
+
tags JSON,
|
|
190
|
+
metadata JSON,
|
|
191
|
+
scope JSON
|
|
166
192
|
)`;
|
|
167
193
|
var FEEDBACK_EVENTS_DDL = `
|
|
168
194
|
CREATE TABLE IF NOT EXISTS feedback_events (
|
|
@@ -173,19 +199,139 @@ CREATE TABLE IF NOT EXISTS feedback_events (
|
|
|
173
199
|
traceId VARCHAR NOT NULL,
|
|
174
200
|
spanId VARCHAR,
|
|
175
201
|
experimentId VARCHAR,
|
|
202
|
+
-- Entity hierarchy
|
|
203
|
+
entityType VARCHAR,
|
|
204
|
+
entityId VARCHAR,
|
|
205
|
+
entityName VARCHAR,
|
|
206
|
+
parentEntityType VARCHAR,
|
|
207
|
+
parentEntityId VARCHAR,
|
|
208
|
+
parentEntityName VARCHAR,
|
|
209
|
+
rootEntityType VARCHAR,
|
|
210
|
+
rootEntityId VARCHAR,
|
|
211
|
+
rootEntityName VARCHAR,
|
|
212
|
+
|
|
213
|
+
-- Context
|
|
176
214
|
userId VARCHAR,
|
|
215
|
+
organizationId VARCHAR,
|
|
216
|
+
resourceId VARCHAR,
|
|
217
|
+
runId VARCHAR,
|
|
218
|
+
sessionId VARCHAR,
|
|
219
|
+
threadId VARCHAR,
|
|
220
|
+
requestId VARCHAR,
|
|
221
|
+
environment VARCHAR,
|
|
222
|
+
executionSource VARCHAR,
|
|
223
|
+
serviceName VARCHAR,
|
|
224
|
+
|
|
225
|
+
-- Feedback actor / linkage
|
|
226
|
+
feedbackUserId VARCHAR,
|
|
177
227
|
sourceId VARCHAR,
|
|
178
228
|
|
|
179
229
|
-- Feedback-specific scalars
|
|
180
|
-
source VARCHAR
|
|
230
|
+
source VARCHAR,
|
|
231
|
+
feedbackSource VARCHAR NOT NULL,
|
|
181
232
|
feedbackType VARCHAR NOT NULL,
|
|
182
233
|
value VARCHAR NOT NULL,
|
|
183
234
|
comment VARCHAR,
|
|
184
235
|
|
|
185
236
|
-- JSON fields
|
|
186
|
-
|
|
237
|
+
tags JSON,
|
|
238
|
+
metadata JSON,
|
|
239
|
+
scope JSON
|
|
187
240
|
)`;
|
|
188
241
|
var ALL_DDL = [SPAN_EVENTS_DDL, METRIC_EVENTS_DDL, LOG_EVENTS_DDL, SCORE_EVENTS_DDL, FEEDBACK_EVENTS_DDL];
|
|
242
|
+
var ALL_MIGRATIONS = [
|
|
243
|
+
// Metrics
|
|
244
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS experimentId VARCHAR`,
|
|
245
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS parentEntityType VARCHAR`,
|
|
246
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS parentEntityId VARCHAR`,
|
|
247
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS parentEntityName VARCHAR`,
|
|
248
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS rootEntityType VARCHAR`,
|
|
249
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS rootEntityId VARCHAR`,
|
|
250
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS rootEntityName VARCHAR`,
|
|
251
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS userId VARCHAR`,
|
|
252
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS organizationId VARCHAR`,
|
|
253
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS resourceId VARCHAR`,
|
|
254
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS runId VARCHAR`,
|
|
255
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS sessionId VARCHAR`,
|
|
256
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS threadId VARCHAR`,
|
|
257
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS requestId VARCHAR`,
|
|
258
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS environment VARCHAR`,
|
|
259
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS executionSource VARCHAR`,
|
|
260
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS serviceName VARCHAR`,
|
|
261
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS costMetadata JSON`,
|
|
262
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS metadata JSON`,
|
|
263
|
+
`ALTER TABLE metric_events ADD COLUMN IF NOT EXISTS scope JSON`,
|
|
264
|
+
// Logs
|
|
265
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS experimentId VARCHAR`,
|
|
266
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS parentEntityType VARCHAR`,
|
|
267
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS parentEntityId VARCHAR`,
|
|
268
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS parentEntityName VARCHAR`,
|
|
269
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS rootEntityType VARCHAR`,
|
|
270
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS rootEntityId VARCHAR`,
|
|
271
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS rootEntityName VARCHAR`,
|
|
272
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS userId VARCHAR`,
|
|
273
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS organizationId VARCHAR`,
|
|
274
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS resourceId VARCHAR`,
|
|
275
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS runId VARCHAR`,
|
|
276
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS sessionId VARCHAR`,
|
|
277
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS threadId VARCHAR`,
|
|
278
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS requestId VARCHAR`,
|
|
279
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS environment VARCHAR`,
|
|
280
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS executionSource VARCHAR`,
|
|
281
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS serviceName VARCHAR`,
|
|
282
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS tags JSON`,
|
|
283
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS metadata JSON`,
|
|
284
|
+
`ALTER TABLE log_events ADD COLUMN IF NOT EXISTS scope JSON`,
|
|
285
|
+
// Scores
|
|
286
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS entityType VARCHAR`,
|
|
287
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS entityId VARCHAR`,
|
|
288
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS entityName VARCHAR`,
|
|
289
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS parentEntityType VARCHAR`,
|
|
290
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS parentEntityId VARCHAR`,
|
|
291
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS parentEntityName VARCHAR`,
|
|
292
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS rootEntityType VARCHAR`,
|
|
293
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS rootEntityId VARCHAR`,
|
|
294
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS rootEntityName VARCHAR`,
|
|
295
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS userId VARCHAR`,
|
|
296
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS organizationId VARCHAR`,
|
|
297
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS resourceId VARCHAR`,
|
|
298
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS runId VARCHAR`,
|
|
299
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS sessionId VARCHAR`,
|
|
300
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS threadId VARCHAR`,
|
|
301
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS requestId VARCHAR`,
|
|
302
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS environment VARCHAR`,
|
|
303
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS executionSource VARCHAR`,
|
|
304
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS serviceName VARCHAR`,
|
|
305
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS tags JSON`,
|
|
306
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS scope JSON`,
|
|
307
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS source VARCHAR`,
|
|
308
|
+
`ALTER TABLE score_events ADD COLUMN IF NOT EXISTS scoreSource VARCHAR`,
|
|
309
|
+
// Feedback
|
|
310
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS entityType VARCHAR`,
|
|
311
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS entityId VARCHAR`,
|
|
312
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS entityName VARCHAR`,
|
|
313
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS parentEntityType VARCHAR`,
|
|
314
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS parentEntityId VARCHAR`,
|
|
315
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS parentEntityName VARCHAR`,
|
|
316
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS rootEntityType VARCHAR`,
|
|
317
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS rootEntityId VARCHAR`,
|
|
318
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS rootEntityName VARCHAR`,
|
|
319
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS organizationId VARCHAR`,
|
|
320
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS resourceId VARCHAR`,
|
|
321
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS runId VARCHAR`,
|
|
322
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS sessionId VARCHAR`,
|
|
323
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS threadId VARCHAR`,
|
|
324
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS requestId VARCHAR`,
|
|
325
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS environment VARCHAR`,
|
|
326
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS executionSource VARCHAR`,
|
|
327
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS serviceName VARCHAR`,
|
|
328
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS feedbackUserId VARCHAR`,
|
|
329
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS sourceId VARCHAR`,
|
|
330
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS tags JSON`,
|
|
331
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS scope JSON`,
|
|
332
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS source VARCHAR`,
|
|
333
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS feedbackSource VARCHAR`
|
|
334
|
+
];
|
|
189
335
|
function unionDistinctQueries(selects, orderBy) {
|
|
190
336
|
return `${selects.join("\nUNION\n")}
|
|
191
337
|
ORDER BY ${orderBy}`;
|
|
@@ -292,7 +438,7 @@ function buildWhereClause(filters, fieldMappings) {
|
|
|
292
438
|
const params = [];
|
|
293
439
|
for (const [key, value] of Object.entries(filters)) {
|
|
294
440
|
if (value === void 0 || value === null) continue;
|
|
295
|
-
const column = sanitizeColumn(key);
|
|
441
|
+
const column = sanitizeColumn(fieldMappings?.[key] ?? key);
|
|
296
442
|
if (key === "timestamp" || key === "startedAt" || key === "endedAt") {
|
|
297
443
|
const dateRange = value;
|
|
298
444
|
if (dateRange.start) {
|
|
@@ -424,42 +570,99 @@ function parseJsonArray(value) {
|
|
|
424
570
|
// src/storage/domains/observability/feedback.ts
|
|
425
571
|
async function createFeedback(db, args) {
|
|
426
572
|
const f = args.feedback;
|
|
573
|
+
const feedbackSource = f.feedbackSource ?? f.source ?? "";
|
|
574
|
+
const feedbackUserId = f.feedbackUserId ?? f.userId ?? null;
|
|
427
575
|
await db.execute(
|
|
428
|
-
`INSERT INTO feedback_events (
|
|
576
|
+
`INSERT INTO feedback_events (
|
|
577
|
+
timestamp, traceId, spanId, experimentId,
|
|
578
|
+
entityType, entityId, entityName, parentEntityType, parentEntityId, parentEntityName, rootEntityType, rootEntityId, rootEntityName,
|
|
579
|
+
userId, organizationId, resourceId, runId, sessionId, threadId, requestId, environment, executionSource, serviceName,
|
|
580
|
+
feedbackUserId, sourceId, feedbackSource, feedbackType, value, comment, tags, metadata, scope
|
|
581
|
+
)
|
|
429
582
|
VALUES (${[
|
|
430
583
|
v(f.timestamp),
|
|
431
584
|
v(f.traceId),
|
|
432
585
|
v(f.spanId ?? null),
|
|
433
586
|
v(f.experimentId ?? null),
|
|
587
|
+
v(f.entityType ?? null),
|
|
588
|
+
v(f.entityId ?? null),
|
|
589
|
+
v(f.entityName ?? null),
|
|
590
|
+
v(f.parentEntityType ?? null),
|
|
591
|
+
v(f.parentEntityId ?? null),
|
|
592
|
+
v(f.parentEntityName ?? null),
|
|
593
|
+
v(f.rootEntityType ?? null),
|
|
594
|
+
v(f.rootEntityId ?? null),
|
|
595
|
+
v(f.rootEntityName ?? null),
|
|
434
596
|
v(f.userId ?? null),
|
|
597
|
+
v(f.organizationId ?? null),
|
|
598
|
+
v(f.resourceId ?? null),
|
|
599
|
+
v(f.runId ?? null),
|
|
600
|
+
v(f.sessionId ?? null),
|
|
601
|
+
v(f.threadId ?? null),
|
|
602
|
+
v(f.requestId ?? null),
|
|
603
|
+
v(f.environment ?? null),
|
|
604
|
+
v(f.executionSource ?? null),
|
|
605
|
+
v(f.serviceName ?? null),
|
|
606
|
+
v(feedbackUserId),
|
|
435
607
|
v(f.sourceId ?? null),
|
|
436
|
-
v(
|
|
608
|
+
v(feedbackSource),
|
|
437
609
|
v(f.feedbackType),
|
|
438
610
|
v(String(f.value)),
|
|
439
611
|
v(f.comment ?? null),
|
|
440
|
-
jsonV(f.
|
|
612
|
+
jsonV(f.tags ?? null),
|
|
613
|
+
jsonV(f.metadata),
|
|
614
|
+
jsonV(f.scope ?? null)
|
|
441
615
|
].join(", ")})`
|
|
442
616
|
);
|
|
443
617
|
}
|
|
444
618
|
async function batchCreateFeedback(db, args) {
|
|
445
619
|
if (args.feedbacks.length === 0) return;
|
|
446
|
-
const tuples = args.feedbacks.map(
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
v(
|
|
452
|
-
v(
|
|
453
|
-
v(
|
|
454
|
-
v(
|
|
455
|
-
v(
|
|
456
|
-
v(
|
|
457
|
-
v(
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
620
|
+
const tuples = args.feedbacks.map((f) => {
|
|
621
|
+
const legacyFeedback = f;
|
|
622
|
+
const feedbackSource = legacyFeedback.feedbackSource ?? legacyFeedback.source ?? "";
|
|
623
|
+
const feedbackUserId = legacyFeedback.feedbackUserId ?? legacyFeedback.userId ?? null;
|
|
624
|
+
return `(${[
|
|
625
|
+
v(legacyFeedback.timestamp),
|
|
626
|
+
v(legacyFeedback.traceId),
|
|
627
|
+
v(legacyFeedback.spanId ?? null),
|
|
628
|
+
v(legacyFeedback.experimentId ?? null),
|
|
629
|
+
v(legacyFeedback.entityType ?? null),
|
|
630
|
+
v(legacyFeedback.entityId ?? null),
|
|
631
|
+
v(legacyFeedback.entityName ?? null),
|
|
632
|
+
v(legacyFeedback.parentEntityType ?? null),
|
|
633
|
+
v(legacyFeedback.parentEntityId ?? null),
|
|
634
|
+
v(legacyFeedback.parentEntityName ?? null),
|
|
635
|
+
v(legacyFeedback.rootEntityType ?? null),
|
|
636
|
+
v(legacyFeedback.rootEntityId ?? null),
|
|
637
|
+
v(legacyFeedback.rootEntityName ?? null),
|
|
638
|
+
v(legacyFeedback.userId ?? null),
|
|
639
|
+
v(legacyFeedback.organizationId ?? null),
|
|
640
|
+
v(legacyFeedback.resourceId ?? null),
|
|
641
|
+
v(legacyFeedback.runId ?? null),
|
|
642
|
+
v(legacyFeedback.sessionId ?? null),
|
|
643
|
+
v(legacyFeedback.threadId ?? null),
|
|
644
|
+
v(legacyFeedback.requestId ?? null),
|
|
645
|
+
v(legacyFeedback.environment ?? null),
|
|
646
|
+
v(legacyFeedback.executionSource ?? null),
|
|
647
|
+
v(legacyFeedback.serviceName ?? null),
|
|
648
|
+
v(feedbackUserId),
|
|
649
|
+
v(legacyFeedback.sourceId ?? null),
|
|
650
|
+
v(feedbackSource),
|
|
651
|
+
v(legacyFeedback.feedbackType),
|
|
652
|
+
v(String(legacyFeedback.value)),
|
|
653
|
+
v(legacyFeedback.comment ?? null),
|
|
654
|
+
jsonV(legacyFeedback.tags ?? null),
|
|
655
|
+
jsonV(legacyFeedback.metadata),
|
|
656
|
+
jsonV(legacyFeedback.scope ?? null)
|
|
657
|
+
].join(", ")})`;
|
|
658
|
+
});
|
|
461
659
|
await db.execute(
|
|
462
|
-
`INSERT INTO feedback_events (
|
|
660
|
+
`INSERT INTO feedback_events (
|
|
661
|
+
timestamp, traceId, spanId, experimentId,
|
|
662
|
+
entityType, entityId, entityName, parentEntityType, parentEntityId, parentEntityName, rootEntityType, rootEntityId, rootEntityName,
|
|
663
|
+
userId, organizationId, resourceId, runId, sessionId, threadId, requestId, environment, executionSource, serviceName,
|
|
664
|
+
feedbackUserId, sourceId, feedbackSource, feedbackType, value, comment, tags, metadata, scope
|
|
665
|
+
)
|
|
463
666
|
VALUES ${tuples.join(",\n ")}`
|
|
464
667
|
);
|
|
465
668
|
}
|
|
@@ -468,7 +671,9 @@ async function listFeedback(db, args) {
|
|
|
468
671
|
const page = Number(args.pagination?.page ?? 0);
|
|
469
672
|
const perPage = Number(args.pagination?.perPage ?? 10);
|
|
470
673
|
const orderBy = { field: args.orderBy?.field ?? "timestamp", direction: args.orderBy?.direction ?? "DESC" };
|
|
471
|
-
const { clause: filterClause, params: filterParams } = buildWhereClause(filters
|
|
674
|
+
const { clause: filterClause, params: filterParams } = buildWhereClause(filters, {
|
|
675
|
+
source: "feedbackSource"
|
|
676
|
+
});
|
|
472
677
|
const orderByClause = buildOrderByClause(orderBy);
|
|
473
678
|
const { clause: paginationClause, params: paginationParams } = buildPaginationClause({ page, perPage });
|
|
474
679
|
const countResult = await db.query(
|
|
@@ -491,13 +696,35 @@ async function listFeedback(db, args) {
|
|
|
491
696
|
traceId: r.traceId,
|
|
492
697
|
spanId: r.spanId ?? null,
|
|
493
698
|
experimentId: r.experimentId ?? null,
|
|
699
|
+
entityType: r.entityType ?? null,
|
|
700
|
+
entityId: r.entityId ?? null,
|
|
701
|
+
entityName: r.entityName ?? null,
|
|
702
|
+
parentEntityType: r.parentEntityType ?? null,
|
|
703
|
+
parentEntityId: r.parentEntityId ?? null,
|
|
704
|
+
parentEntityName: r.parentEntityName ?? null,
|
|
705
|
+
rootEntityType: r.rootEntityType ?? null,
|
|
706
|
+
rootEntityId: r.rootEntityId ?? null,
|
|
707
|
+
rootEntityName: r.rootEntityName ?? null,
|
|
494
708
|
userId: r.userId ?? null,
|
|
709
|
+
organizationId: r.organizationId ?? null,
|
|
710
|
+
resourceId: r.resourceId ?? null,
|
|
711
|
+
runId: r.runId ?? null,
|
|
712
|
+
sessionId: r.sessionId ?? null,
|
|
713
|
+
threadId: r.threadId ?? null,
|
|
714
|
+
requestId: r.requestId ?? null,
|
|
715
|
+
environment: r.environment ?? null,
|
|
716
|
+
executionSource: r.executionSource ?? null,
|
|
717
|
+
serviceName: r.serviceName ?? null,
|
|
718
|
+
feedbackUserId: r.feedbackUserId ?? null,
|
|
495
719
|
sourceId: r.sourceId ?? null,
|
|
496
|
-
source: r.
|
|
720
|
+
source: r.feedbackSource,
|
|
721
|
+
feedbackSource: r.feedbackSource,
|
|
497
722
|
feedbackType: r.feedbackType,
|
|
498
723
|
value,
|
|
499
724
|
comment: r.comment ?? null,
|
|
500
|
-
|
|
725
|
+
tags: parseJsonArray(r.tags),
|
|
726
|
+
metadata: parseJson(r.metadata),
|
|
727
|
+
scope: parseJson(r.scope)
|
|
501
728
|
};
|
|
502
729
|
});
|
|
503
730
|
return {
|
|
@@ -531,7 +758,7 @@ var COLUMNS = [
|
|
|
531
758
|
"threadId",
|
|
532
759
|
"requestId",
|
|
533
760
|
"environment",
|
|
534
|
-
"
|
|
761
|
+
"executionSource",
|
|
535
762
|
"serviceName",
|
|
536
763
|
"experimentId",
|
|
537
764
|
"tags",
|
|
@@ -564,7 +791,7 @@ function rowToLogRecord(row) {
|
|
|
564
791
|
threadId: row.threadId ?? null,
|
|
565
792
|
requestId: row.requestId ?? null,
|
|
566
793
|
environment: row.environment ?? null,
|
|
567
|
-
|
|
794
|
+
executionSource: row.executionSource ?? null,
|
|
568
795
|
serviceName: row.serviceName ?? null,
|
|
569
796
|
experimentId: row.experimentId ?? null,
|
|
570
797
|
tags: parseJsonArray(row.tags),
|
|
@@ -599,7 +826,7 @@ async function batchCreateLogs(db, args) {
|
|
|
599
826
|
v(log.threadId ?? null),
|
|
600
827
|
v(log.requestId ?? null),
|
|
601
828
|
v(log.environment ?? null),
|
|
602
|
-
v(log.
|
|
829
|
+
v(log.executionSource ?? null),
|
|
603
830
|
v(log.serviceName ?? null),
|
|
604
831
|
v(log.experimentId ?? null),
|
|
605
832
|
jsonV(log.tags),
|
|
@@ -696,7 +923,7 @@ var METRIC_COLUMNS = [
|
|
|
696
923
|
"threadId",
|
|
697
924
|
"requestId",
|
|
698
925
|
"environment",
|
|
699
|
-
"
|
|
926
|
+
"executionSource",
|
|
700
927
|
"serviceName",
|
|
701
928
|
"experimentId",
|
|
702
929
|
"provider",
|
|
@@ -796,7 +1023,7 @@ function rowToMetricRecord(row) {
|
|
|
796
1023
|
threadId: row.threadId ?? null,
|
|
797
1024
|
requestId: row.requestId ?? null,
|
|
798
1025
|
environment: row.environment ?? null,
|
|
799
|
-
|
|
1026
|
+
executionSource: row.executionSource ?? null,
|
|
800
1027
|
serviceName: row.serviceName ?? null,
|
|
801
1028
|
experimentId: row.experimentId ?? null,
|
|
802
1029
|
provider: row.provider ?? null,
|
|
@@ -836,7 +1063,7 @@ async function batchCreateMetrics(db, args) {
|
|
|
836
1063
|
v(m.threadId ?? null),
|
|
837
1064
|
v(m.requestId ?? null),
|
|
838
1065
|
v(m.environment ?? null),
|
|
839
|
-
v(m.
|
|
1066
|
+
v(m.executionSource ?? null),
|
|
840
1067
|
v(m.serviceName ?? null),
|
|
841
1068
|
v(m.experimentId ?? null),
|
|
842
1069
|
v(m.provider ?? null),
|
|
@@ -1153,42 +1380,97 @@ async function getMetricLabelValues(db, args) {
|
|
|
1153
1380
|
// src/storage/domains/observability/scores.ts
|
|
1154
1381
|
async function createScore(db, args) {
|
|
1155
1382
|
const s = args.score;
|
|
1383
|
+
const scoreSource = s.scoreSource ?? s.source ?? null;
|
|
1156
1384
|
await db.execute(
|
|
1157
|
-
`INSERT INTO score_events (
|
|
1385
|
+
`INSERT INTO score_events (
|
|
1386
|
+
timestamp, traceId, spanId, experimentId, scoreTraceId,
|
|
1387
|
+
entityType, entityId, entityName, parentEntityType, parentEntityId, parentEntityName, rootEntityType, rootEntityId, rootEntityName,
|
|
1388
|
+
userId, organizationId, resourceId, runId, sessionId, threadId, requestId, environment, executionSource, serviceName,
|
|
1389
|
+
scorerId, scorerVersion, scoreSource, score, reason, tags, metadata, scope
|
|
1390
|
+
)
|
|
1158
1391
|
VALUES (${[
|
|
1159
1392
|
v(s.timestamp),
|
|
1160
1393
|
v(s.traceId),
|
|
1161
1394
|
v(s.spanId ?? null),
|
|
1395
|
+
v(s.experimentId ?? null),
|
|
1396
|
+
v(s.scoreTraceId ?? null),
|
|
1397
|
+
v(s.entityType ?? null),
|
|
1398
|
+
v(s.entityId ?? null),
|
|
1399
|
+
v(s.entityName ?? null),
|
|
1400
|
+
v(s.parentEntityType ?? null),
|
|
1401
|
+
v(s.parentEntityId ?? null),
|
|
1402
|
+
v(s.parentEntityName ?? null),
|
|
1403
|
+
v(s.rootEntityType ?? null),
|
|
1404
|
+
v(s.rootEntityId ?? null),
|
|
1405
|
+
v(s.rootEntityName ?? null),
|
|
1406
|
+
v(s.userId ?? null),
|
|
1407
|
+
v(s.organizationId ?? null),
|
|
1408
|
+
v(s.resourceId ?? null),
|
|
1409
|
+
v(s.runId ?? null),
|
|
1410
|
+
v(s.sessionId ?? null),
|
|
1411
|
+
v(s.threadId ?? null),
|
|
1412
|
+
v(s.requestId ?? null),
|
|
1413
|
+
v(s.environment ?? null),
|
|
1414
|
+
v(s.executionSource ?? null),
|
|
1415
|
+
v(s.serviceName ?? null),
|
|
1162
1416
|
v(s.scorerId),
|
|
1163
1417
|
v(s.scorerVersion ?? null),
|
|
1164
|
-
v(
|
|
1418
|
+
v(scoreSource),
|
|
1165
1419
|
v(s.score),
|
|
1166
1420
|
v(s.reason ?? null),
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
jsonV(s.
|
|
1421
|
+
jsonV(s.tags ?? null),
|
|
1422
|
+
jsonV(s.metadata),
|
|
1423
|
+
jsonV(s.scope ?? null)
|
|
1170
1424
|
].join(", ")})`
|
|
1171
1425
|
);
|
|
1172
1426
|
}
|
|
1173
1427
|
async function batchCreateScores(db, args) {
|
|
1174
1428
|
if (args.scores.length === 0) return;
|
|
1175
|
-
const tuples = args.scores.map(
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
v(
|
|
1180
|
-
v(
|
|
1181
|
-
v(
|
|
1182
|
-
v(
|
|
1183
|
-
v(
|
|
1184
|
-
v(
|
|
1185
|
-
v(
|
|
1186
|
-
v(
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1429
|
+
const tuples = args.scores.map((s) => {
|
|
1430
|
+
const legacyScore = s;
|
|
1431
|
+
const scoreSource = legacyScore.scoreSource ?? legacyScore.source ?? null;
|
|
1432
|
+
return `(${[
|
|
1433
|
+
v(legacyScore.timestamp),
|
|
1434
|
+
v(legacyScore.traceId),
|
|
1435
|
+
v(legacyScore.spanId ?? null),
|
|
1436
|
+
v(legacyScore.experimentId ?? null),
|
|
1437
|
+
v(legacyScore.scoreTraceId ?? null),
|
|
1438
|
+
v(legacyScore.entityType ?? null),
|
|
1439
|
+
v(legacyScore.entityId ?? null),
|
|
1440
|
+
v(legacyScore.entityName ?? null),
|
|
1441
|
+
v(legacyScore.parentEntityType ?? null),
|
|
1442
|
+
v(legacyScore.parentEntityId ?? null),
|
|
1443
|
+
v(legacyScore.parentEntityName ?? null),
|
|
1444
|
+
v(legacyScore.rootEntityType ?? null),
|
|
1445
|
+
v(legacyScore.rootEntityId ?? null),
|
|
1446
|
+
v(legacyScore.rootEntityName ?? null),
|
|
1447
|
+
v(legacyScore.userId ?? null),
|
|
1448
|
+
v(legacyScore.organizationId ?? null),
|
|
1449
|
+
v(legacyScore.resourceId ?? null),
|
|
1450
|
+
v(legacyScore.runId ?? null),
|
|
1451
|
+
v(legacyScore.sessionId ?? null),
|
|
1452
|
+
v(legacyScore.threadId ?? null),
|
|
1453
|
+
v(legacyScore.requestId ?? null),
|
|
1454
|
+
v(legacyScore.environment ?? null),
|
|
1455
|
+
v(legacyScore.executionSource ?? null),
|
|
1456
|
+
v(legacyScore.serviceName ?? null),
|
|
1457
|
+
v(legacyScore.scorerId),
|
|
1458
|
+
v(legacyScore.scorerVersion ?? null),
|
|
1459
|
+
v(scoreSource),
|
|
1460
|
+
v(legacyScore.score),
|
|
1461
|
+
v(legacyScore.reason ?? null),
|
|
1462
|
+
jsonV(legacyScore.tags ?? null),
|
|
1463
|
+
jsonV(legacyScore.metadata),
|
|
1464
|
+
jsonV(legacyScore.scope ?? null)
|
|
1465
|
+
].join(", ")})`;
|
|
1466
|
+
});
|
|
1190
1467
|
await db.execute(
|
|
1191
|
-
`INSERT INTO score_events (
|
|
1468
|
+
`INSERT INTO score_events (
|
|
1469
|
+
timestamp, traceId, spanId, experimentId, scoreTraceId,
|
|
1470
|
+
entityType, entityId, entityName, parentEntityType, parentEntityId, parentEntityName, rootEntityType, rootEntityId, rootEntityName,
|
|
1471
|
+
userId, organizationId, resourceId, runId, sessionId, threadId, requestId, environment, executionSource, serviceName,
|
|
1472
|
+
scorerId, scorerVersion, scoreSource, score, reason, tags, metadata, scope
|
|
1473
|
+
)
|
|
1192
1474
|
VALUES ${tuples.join(",\n ")}`
|
|
1193
1475
|
);
|
|
1194
1476
|
}
|
|
@@ -1197,7 +1479,9 @@ async function listScores(db, args) {
|
|
|
1197
1479
|
const page = Number(args.pagination?.page ?? 0);
|
|
1198
1480
|
const perPage = Number(args.pagination?.perPage ?? 10);
|
|
1199
1481
|
const orderBy = { field: args.orderBy?.field ?? "timestamp", direction: args.orderBy?.direction ?? "DESC" };
|
|
1200
|
-
const { clause: filterClause, params: filterParams } = buildWhereClause(filters
|
|
1482
|
+
const { clause: filterClause, params: filterParams } = buildWhereClause(filters, {
|
|
1483
|
+
source: "scoreSource"
|
|
1484
|
+
});
|
|
1201
1485
|
const orderByClause = buildOrderByClause(orderBy);
|
|
1202
1486
|
const { clause: paginationClause, params: paginationParams } = buildPaginationClause({ page, perPage });
|
|
1203
1487
|
const countResult = await db.query(
|
|
@@ -1215,14 +1499,36 @@ async function listScores(db, args) {
|
|
|
1215
1499
|
timestamp: toDate(r.timestamp),
|
|
1216
1500
|
traceId: r.traceId,
|
|
1217
1501
|
spanId: r.spanId ?? null,
|
|
1502
|
+
experimentId: r.experimentId ?? null,
|
|
1503
|
+
scoreTraceId: r.scoreTraceId ?? null,
|
|
1504
|
+
entityType: r.entityType ?? null,
|
|
1505
|
+
entityId: r.entityId ?? null,
|
|
1506
|
+
entityName: r.entityName ?? null,
|
|
1507
|
+
parentEntityType: r.parentEntityType ?? null,
|
|
1508
|
+
parentEntityId: r.parentEntityId ?? null,
|
|
1509
|
+
parentEntityName: r.parentEntityName ?? null,
|
|
1510
|
+
rootEntityType: r.rootEntityType ?? null,
|
|
1511
|
+
rootEntityId: r.rootEntityId ?? null,
|
|
1512
|
+
rootEntityName: r.rootEntityName ?? null,
|
|
1513
|
+
userId: r.userId ?? null,
|
|
1514
|
+
organizationId: r.organizationId ?? null,
|
|
1515
|
+
resourceId: r.resourceId ?? null,
|
|
1516
|
+
runId: r.runId ?? null,
|
|
1517
|
+
sessionId: r.sessionId ?? null,
|
|
1518
|
+
threadId: r.threadId ?? null,
|
|
1519
|
+
requestId: r.requestId ?? null,
|
|
1520
|
+
environment: r.environment ?? null,
|
|
1521
|
+
executionSource: r.executionSource ?? null,
|
|
1522
|
+
serviceName: r.serviceName ?? null,
|
|
1218
1523
|
scorerId: r.scorerId,
|
|
1219
1524
|
scorerVersion: r.scorerVersion ?? null,
|
|
1220
|
-
source: r.
|
|
1525
|
+
source: r.scoreSource ?? null,
|
|
1526
|
+
scoreSource: r.scoreSource ?? null,
|
|
1221
1527
|
score: Number(r.score),
|
|
1222
1528
|
reason: r.reason ?? null,
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1529
|
+
tags: parseJsonArray(r.tags),
|
|
1530
|
+
metadata: parseJson(r.metadata),
|
|
1531
|
+
scope: parseJson(r.scope)
|
|
1226
1532
|
};
|
|
1227
1533
|
});
|
|
1228
1534
|
return {
|
|
@@ -1563,6 +1869,9 @@ var ObservabilityStorageDuckDB = class extends storage.ObservabilityStorage {
|
|
|
1563
1869
|
for (const ddl of ALL_DDL) {
|
|
1564
1870
|
await this.db.execute(ddl);
|
|
1565
1871
|
}
|
|
1872
|
+
for (const migration of ALL_MIGRATIONS) {
|
|
1873
|
+
await this.db.execute(migration);
|
|
1874
|
+
}
|
|
1566
1875
|
}
|
|
1567
1876
|
/** Delete all rows from every observability table. Use with caution. */
|
|
1568
1877
|
async dangerouslyClearAll() {
|
|
@@ -1673,5 +1982,5 @@ var ObservabilityStorageDuckDB = class extends storage.ObservabilityStorage {
|
|
|
1673
1982
|
};
|
|
1674
1983
|
|
|
1675
1984
|
exports.ObservabilityStorageDuckDB = ObservabilityStorageDuckDB;
|
|
1676
|
-
//# sourceMappingURL=observability-
|
|
1677
|
-
//# sourceMappingURL=observability-
|
|
1985
|
+
//# sourceMappingURL=observability-AMG7NSKE.cjs.map
|
|
1986
|
+
//# sourceMappingURL=observability-AMG7NSKE.cjs.map
|