@mastra/duckdb 1.11.0 → 1.11.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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +17 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -3
- package/dist/index.js.map +1 -1
- package/dist/{observability-D276d4Zq.cjs → observability-B8uK8pWn.cjs} +45 -19
- package/dist/{observability-D276d4Zq.cjs.map → observability-B8uK8pWn.cjs.map} +1 -1
- package/dist/{observability-CDtl20Mc.js → observability-BVE7R9Oz.js} +45 -19
- package/dist/{observability-CDtl20Mc.js.map → observability-BVE7R9Oz.js.map} +1 -1
- package/dist/storage/domains/observability/index.d.ts +1 -1
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/tracing.d.ts.map +1 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -3773,6 +3773,14 @@ function reconstructForAnchorsWithBoundParam(reconstructSelect, anchorCte) {
|
|
|
3773
3773
|
AND (traceId, spanId) IN (SELECT traceId, spanId FROM ${anchorCte})
|
|
3774
3774
|
GROUP BY traceId, spanId`;
|
|
3775
3775
|
}
|
|
3776
|
+
/**
|
|
3777
|
+
* Event spans are point-in-time, so they end at the instant they start. Rows
|
|
3778
|
+
* written before event spans carried an end time have a null endedAt.
|
|
3779
|
+
*/
|
|
3780
|
+
function rowEndedAt(row) {
|
|
3781
|
+
if (row.isEvent) return toDate(row.startedAt);
|
|
3782
|
+
return toDateOrNull(row.endedAt);
|
|
3783
|
+
}
|
|
3776
3784
|
function rowToLightSpanRecord(row) {
|
|
3777
3785
|
return {
|
|
3778
3786
|
traceId: row.traceId,
|
|
@@ -3782,13 +3790,13 @@ function rowToLightSpanRecord(row) {
|
|
|
3782
3790
|
parentSpanId: row.parentSpanId ?? null,
|
|
3783
3791
|
isEvent: row.isEvent,
|
|
3784
3792
|
startedAt: toDate(row.startedAt),
|
|
3785
|
-
endedAt:
|
|
3793
|
+
endedAt: rowEndedAt(row),
|
|
3786
3794
|
entityType: row.entityType ?? null,
|
|
3787
3795
|
entityId: row.entityId ?? null,
|
|
3788
3796
|
entityName: row.entityName ?? null,
|
|
3789
3797
|
error: parseJson(row.error),
|
|
3790
3798
|
createdAt: toDate(row.startedAt),
|
|
3791
|
-
updatedAt:
|
|
3799
|
+
updatedAt: rowEndedAt(row)
|
|
3792
3800
|
};
|
|
3793
3801
|
}
|
|
3794
3802
|
function rowToLightSpanRecordWithPreview(row) {
|
|
@@ -3809,7 +3817,7 @@ function rowToSpanRecord(row) {
|
|
|
3809
3817
|
parentSpanId: row.parentSpanId ?? null,
|
|
3810
3818
|
isEvent: row.isEvent,
|
|
3811
3819
|
startedAt: toDate(row.startedAt),
|
|
3812
|
-
endedAt:
|
|
3820
|
+
endedAt: rowEndedAt(row),
|
|
3813
3821
|
experimentId: row.experimentId ?? null,
|
|
3814
3822
|
entityType: row.entityType ?? null,
|
|
3815
3823
|
entityId: row.entityId ?? null,
|
|
@@ -4010,7 +4018,7 @@ function createStartSpanRow(s) {
|
|
|
4010
4018
|
name: s.name,
|
|
4011
4019
|
spanType: s.spanType,
|
|
4012
4020
|
isEvent: s.isEvent,
|
|
4013
|
-
endedAt: null,
|
|
4021
|
+
endedAt: s.isEvent ? s.startedAt : null,
|
|
4014
4022
|
experimentId: s.experimentId ?? null,
|
|
4015
4023
|
entityType: s.entityType ?? null,
|
|
4016
4024
|
entityId: s.entityId ?? null,
|
|
@@ -4081,7 +4089,7 @@ function createEndSpanRow(s) {
|
|
|
4081
4089
|
/** Insert a 'start' event for a new span. */
|
|
4082
4090
|
async function createSpan(db, args) {
|
|
4083
4091
|
const rows = [createStartSpanRow(args.span)];
|
|
4084
|
-
if (args.span.endedAt) rows.push(createEndSpanRow(args.span));
|
|
4092
|
+
if (args.span.endedAt && !args.span.isEvent) rows.push(createEndSpanRow(args.span));
|
|
4085
4093
|
await insertSpanEvents(db, rows);
|
|
4086
4094
|
}
|
|
4087
4095
|
/** Insert 'start' events for multiple spans in a single statement. */
|
|
@@ -4089,7 +4097,7 @@ async function batchCreateSpans(db, args) {
|
|
|
4089
4097
|
if (args.records.length === 0) return;
|
|
4090
4098
|
await insertSpanEvents(db, args.records.flatMap((record) => {
|
|
4091
4099
|
const events = [createStartSpanRow(record)];
|
|
4092
|
-
if (record.endedAt) events.push(createEndSpanRow(record));
|
|
4100
|
+
if (record.endedAt && !record.isEvent) events.push(createEndSpanRow(record));
|
|
4093
4101
|
return events;
|
|
4094
4102
|
}));
|
|
4095
4103
|
}
|
|
@@ -4187,10 +4195,10 @@ async function listTraceRows(db, args, reconstructSelect, mapRow, toSpans) {
|
|
|
4187
4195
|
if (orderDir !== "ASC" && orderDir !== "DESC") throw new Error(`Invalid sort direction: ${orderBy.direction}`);
|
|
4188
4196
|
const canOrderInPrefilter = SAFE_PREFILTER_ORDER_FIELDS.has(orderBy.field);
|
|
4189
4197
|
if (!(Object.keys(postAgg).length > 0 || hasChildError !== void 0 || !canOrderInPrefilter)) {
|
|
4190
|
-
const prefilterOrderBy = `ORDER BY
|
|
4198
|
+
const prefilterOrderBy = `ORDER BY anchorStartedAt ${orderDir}, traceId, spanId`;
|
|
4191
4199
|
const offset = page * perPage;
|
|
4192
4200
|
const countSql = `
|
|
4193
|
-
SELECT COUNT(
|
|
4201
|
+
SELECT COUNT(DISTINCT (traceId, spanId)) as total
|
|
4194
4202
|
FROM span_events AS ${outerAlias}
|
|
4195
4203
|
${prefilterWhere}
|
|
4196
4204
|
`;
|
|
@@ -4198,14 +4206,15 @@ async function listTraceRows(db, args, reconstructSelect, mapRow, toSpans) {
|
|
|
4198
4206
|
const total = Number(countResult[0]?.total ?? 0);
|
|
4199
4207
|
const pageSql = `
|
|
4200
4208
|
WITH page_roots AS (
|
|
4201
|
-
SELECT traceId, spanId, timestamp AS anchorStartedAt
|
|
4209
|
+
SELECT traceId, spanId, min(timestamp) AS anchorStartedAt
|
|
4202
4210
|
FROM span_events AS ${outerAlias}
|
|
4203
4211
|
${prefilterWhere}
|
|
4212
|
+
GROUP BY traceId, spanId
|
|
4204
4213
|
${prefilterOrderBy}
|
|
4205
4214
|
LIMIT ? OFFSET ?
|
|
4206
4215
|
)
|
|
4207
4216
|
${reconstructForAnchors(reconstructSelect, "page_roots")}
|
|
4208
|
-
${buildOrderByClause(orderBy)}
|
|
4217
|
+
${buildOrderByClause(orderBy)}, traceId, spanId
|
|
4209
4218
|
`;
|
|
4210
4219
|
const spans = (await db.query(pageSql, [
|
|
4211
4220
|
...prefilterParams,
|
|
@@ -4318,9 +4327,10 @@ async function listTraces(db, args) {
|
|
|
4318
4327
|
};
|
|
4319
4328
|
const dataSql = `
|
|
4320
4329
|
WITH candidate_roots AS (
|
|
4321
|
-
SELECT traceId, spanId, cursorId
|
|
4330
|
+
SELECT traceId, spanId, max(cursorId) AS cursorId
|
|
4322
4331
|
FROM span_events AS ${outerAlias}
|
|
4323
4332
|
${prefilterWhere}
|
|
4333
|
+
GROUP BY traceId, spanId
|
|
4324
4334
|
),
|
|
4325
4335
|
root_spans AS (
|
|
4326
4336
|
SELECT reconstructed.*, candidate_roots.cursorId AS anchorCursorId
|
|
@@ -4494,9 +4504,10 @@ async function listBranches(db, args) {
|
|
|
4494
4504
|
};
|
|
4495
4505
|
const dataSql = `
|
|
4496
4506
|
WITH candidate_anchors AS (
|
|
4497
|
-
SELECT traceId, spanId, cursorId
|
|
4507
|
+
SELECT traceId, spanId, max(cursorId) AS cursorId
|
|
4498
4508
|
FROM span_events AS ${outerAlias}
|
|
4499
4509
|
${prefilterWhere}
|
|
4510
|
+
GROUP BY traceId, spanId
|
|
4500
4511
|
),
|
|
4501
4512
|
branch_anchors AS (
|
|
4502
4513
|
SELECT reconstructed.*, candidate_anchors.cursorId AS anchorCursorId
|
|
@@ -4547,10 +4558,10 @@ async function listBranches(db, args) {
|
|
|
4547
4558
|
const currentDeltaCursor = deltaPollingFeatureEnabled() ? await getBranchDeltaCursor(db, filters) : void 0;
|
|
4548
4559
|
const canOrderInPrefilter = SAFE_PREFILTER_ORDER_FIELDS.has(orderBy.field);
|
|
4549
4560
|
if (!(Object.keys(postAgg).length > 0 || !canOrderInPrefilter)) {
|
|
4550
|
-
const prefilterOrderBy = `ORDER BY
|
|
4561
|
+
const prefilterOrderBy = `ORDER BY anchorStartedAt ${orderDir}, traceId, spanId`;
|
|
4551
4562
|
const offset = page * perPage;
|
|
4552
4563
|
const countSql = `
|
|
4553
|
-
SELECT COUNT(
|
|
4564
|
+
SELECT COUNT(DISTINCT (traceId, spanId)) as total
|
|
4554
4565
|
FROM span_events AS ${outerAlias}
|
|
4555
4566
|
${prefilterWhere}
|
|
4556
4567
|
`;
|
|
@@ -4568,14 +4579,15 @@ async function listBranches(db, args) {
|
|
|
4568
4579
|
};
|
|
4569
4580
|
const pageSql = `
|
|
4570
4581
|
WITH page_anchors AS (
|
|
4571
|
-
SELECT traceId, spanId, timestamp AS anchorStartedAt
|
|
4582
|
+
SELECT traceId, spanId, min(timestamp) AS anchorStartedAt
|
|
4572
4583
|
FROM span_events AS ${outerAlias}
|
|
4573
4584
|
${prefilterWhere}
|
|
4585
|
+
GROUP BY traceId, spanId
|
|
4574
4586
|
${prefilterOrderBy}
|
|
4575
4587
|
LIMIT ? OFFSET ?
|
|
4576
4588
|
)
|
|
4577
4589
|
${reconstructForAnchors(SPAN_RECONSTRUCT_SELECT, "page_anchors")}
|
|
4578
|
-
${buildOrderByClause(orderBy)}
|
|
4590
|
+
${buildOrderByClause(orderBy)}, traceId, spanId
|
|
4579
4591
|
`;
|
|
4580
4592
|
const spans = (await db.query(pageSql, [
|
|
4581
4593
|
...prefilterParams,
|
|
@@ -4870,21 +4882,35 @@ var ObservabilityStorageDuckDB = class ObservabilityStorageDuckDB extends Observ
|
|
|
4870
4882
|
if (!deltaPollingFeatureEnabled()) return [
|
|
4871
4883
|
"metrics",
|
|
4872
4884
|
"logs",
|
|
4885
|
+
"entity-type-discovery",
|
|
4886
|
+
"entity-name-discovery",
|
|
4887
|
+
"service-name-discovery",
|
|
4888
|
+
"environment-discovery",
|
|
4889
|
+
"tag-discovery",
|
|
4890
|
+
"metric-discovery",
|
|
4873
4891
|
"trace-query",
|
|
4874
4892
|
"trace-query-root-duration",
|
|
4875
4893
|
"trace-query-discovery",
|
|
4876
4894
|
"thread-query",
|
|
4877
|
-
"trace-query-tenant-scope"
|
|
4895
|
+
"trace-query-tenant-scope",
|
|
4896
|
+
"feedback"
|
|
4878
4897
|
];
|
|
4879
4898
|
return [
|
|
4880
4899
|
"metrics",
|
|
4881
4900
|
"logs",
|
|
4901
|
+
"entity-type-discovery",
|
|
4902
|
+
"entity-name-discovery",
|
|
4903
|
+
"service-name-discovery",
|
|
4904
|
+
"environment-discovery",
|
|
4905
|
+
"tag-discovery",
|
|
4906
|
+
"metric-discovery",
|
|
4882
4907
|
"delta-polling",
|
|
4883
4908
|
"trace-query",
|
|
4884
4909
|
"trace-query-root-duration",
|
|
4885
4910
|
"trace-query-discovery",
|
|
4886
4911
|
"thread-query",
|
|
4887
|
-
"trace-query-tenant-scope"
|
|
4912
|
+
"trace-query-tenant-scope",
|
|
4913
|
+
"feedback"
|
|
4888
4914
|
];
|
|
4889
4915
|
}
|
|
4890
4916
|
async createSpan(args) {
|
|
@@ -5039,4 +5065,4 @@ var ObservabilityStorageDuckDB = class ObservabilityStorageDuckDB extends Observ
|
|
|
5039
5065
|
//#endregion
|
|
5040
5066
|
export { ObservabilityStorageDuckDB };
|
|
5041
5067
|
|
|
5042
|
-
//# sourceMappingURL=observability-
|
|
5068
|
+
//# sourceMappingURL=observability-BVE7R9Oz.js.map
|