@mastra/clickhouse 1.28.0-alpha.2 → 1.29.0-alpha.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/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +37 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -2
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/observability/v-next/index.d.ts +1 -1
- package/dist/storage/domains/observability/v-next/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/trace-aggregate.d.ts +5 -0
- package/dist/storage/domains/observability/v-next/trace-aggregate.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-clickhouse
|
|
|
3
3
|
description: Documentation for @mastra/clickhouse. Use when working with @mastra/clickhouse APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/clickhouse"
|
|
6
|
-
version: "1.
|
|
6
|
+
version: "1.29.0-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
package/dist/index.cjs
CHANGED
|
@@ -8843,6 +8843,27 @@ const PERCENTILES = {
|
|
|
8843
8843
|
"duration.p95": .95,
|
|
8844
8844
|
"duration.p99": .99
|
|
8845
8845
|
};
|
|
8846
|
+
/** Quantile for each percentile statistic of a time-to-first measure. */
|
|
8847
|
+
const STATISTIC_PERCENTILES = {
|
|
8848
|
+
p50: .5,
|
|
8849
|
+
p90: .9,
|
|
8850
|
+
p95: .95,
|
|
8851
|
+
p99: .99
|
|
8852
|
+
};
|
|
8853
|
+
/**
|
|
8854
|
+
* Store features this compiler supports beyond `trace-aggregate` / `span-aggregate`. Core before
|
|
8855
|
+
* the time-to-first measures rejects them, so they are only declared when core plans them.
|
|
8856
|
+
*/
|
|
8857
|
+
const aggregateTimeToFirstFeatures = "timeToFirstToken.p50" in _mastra_core_storage.TRACE_AGGREGATE_MEASURE_REGISTRY ? ["aggregate-time-to-first-measures"] : [];
|
|
8858
|
+
/** The nullable span columns read by the plan's time-to-first measures. */
|
|
8859
|
+
function timeToFirstFields(plan) {
|
|
8860
|
+
const fields = /* @__PURE__ */ new Set();
|
|
8861
|
+
for (const measure of plan.measures) {
|
|
8862
|
+
const field = measureRule(measure.name)?.field;
|
|
8863
|
+
if (field) fields.add(field);
|
|
8864
|
+
}
|
|
8865
|
+
return [...fields];
|
|
8866
|
+
}
|
|
8846
8867
|
const COMPARISON_SQL = {
|
|
8847
8868
|
eq: "=",
|
|
8848
8869
|
ne: "!=",
|
|
@@ -8882,7 +8903,11 @@ function compileClickHouseTraceAggregate(plan) {
|
|
|
8882
8903
|
function compileClickHouseSpanAggregate(plan) {
|
|
8883
8904
|
const parameters = new ParameterBuilder();
|
|
8884
8905
|
return compileClickHouseAggregate(plan, parameters, {
|
|
8885
|
-
ctes: compileClickHouseSpanSelection(plan, [
|
|
8906
|
+
ctes: compileClickHouseSpanSelection(plan, [
|
|
8907
|
+
...plan.dimensions,
|
|
8908
|
+
...plan.measures.flatMap((measure) => measure.type === "countDistinct" && measure.field !== "traceId" ? [measure.field] : []),
|
|
8909
|
+
...timeToFirstFields(plan)
|
|
8910
|
+
], parameters),
|
|
8886
8911
|
from: "selected",
|
|
8887
8912
|
dimensionSql: (field) => lookupDimensionSql(SPAN_DIMENSION_SQL, field),
|
|
8888
8913
|
isErrorSql: "r.status = 'error'",
|
|
@@ -8908,7 +8933,7 @@ function compileClickHouseAggregate(plan, parameters, source) {
|
|
|
8908
8933
|
distinctColumns.set(measure.field, column);
|
|
8909
8934
|
factColumns.push(`CAST(${distinctSql(measure.field)} AS Nullable(String)) AS ${column}`);
|
|
8910
8935
|
}
|
|
8911
|
-
factColumns.push(`toFloat64(${durationMsSql("r.startedAt", "r.endedAt")}) AS durationMs`, `${source.isErrorSql} AS isError`, `cityHash64(${source.usageKey.map((column) => `r.${column}`).join(", ")}) AS traceSeed`);
|
|
8936
|
+
factColumns.push(`toFloat64(${durationMsSql("r.startedAt", "r.endedAt")}) AS durationMs`, `${source.isErrorSql} AS isError`, `cityHash64(${source.usageKey.map((column) => `r.${column}`).join(", ")}) AS traceSeed`, ...timeToFirstFields(plan).map((field) => `toNullable(toFloat64(r.${field})) AS ${field}`));
|
|
8912
8937
|
if (plan.interval !== void 0) {
|
|
8913
8938
|
const intervalMs = _mastra_core_storage.TRACE_AGGREGATE_INTERVAL_MS[plan.interval];
|
|
8914
8939
|
if (intervalMs === void 0) throw new Error(`Unsupported trusted trace-aggregate interval: ${plan.interval}`);
|
|
@@ -8939,6 +8964,14 @@ function compileClickHouseAggregate(plan, parameters, source) {
|
|
|
8939
8964
|
const aggregate = rule.statistic === "avg" ? "avgOrNull" : "sumOrNull";
|
|
8940
8965
|
return `if(${mixedUnitsSql}, NULL, toFloat64(${aggregate}(traceCost)))`;
|
|
8941
8966
|
}
|
|
8967
|
+
if (rule?.field) {
|
|
8968
|
+
if (rule.statistic === "count") return `toFloat64(count(${rule.field}))`;
|
|
8969
|
+
if (rule.statistic === "avg") return `avgOrNull(${rule.field})`;
|
|
8970
|
+
if (rule.statistic === "min") return `minOrNull(${rule.field})`;
|
|
8971
|
+
if (rule.statistic === "max") return `maxOrNull(${rule.field})`;
|
|
8972
|
+
const quantile = rule.statistic && STATISTIC_PERCENTILES[rule.statistic];
|
|
8973
|
+
if (quantile !== void 0) return `quantileDeterministicOrNull(${quantile})(${rule.field}, traceSeed)`;
|
|
8974
|
+
}
|
|
8942
8975
|
if (name === "errorCount") return "toFloat64(countIf(isError))";
|
|
8943
8976
|
if (name === "errorRate") return "countIf(isError) / count()";
|
|
8944
8977
|
if (name === "duration.avg") return "avg(durationMs)";
|
|
@@ -10446,6 +10479,7 @@ var ObservabilityStorageClickhouseVNext = class extends _mastra_core_storage.Obs
|
|
|
10446
10479
|
"trace-query-root-span-fields",
|
|
10447
10480
|
"trace-query-root-entity-id",
|
|
10448
10481
|
"trace-aggregate",
|
|
10482
|
+
...aggregateTimeToFirstFeatures,
|
|
10449
10483
|
...spanQueryFeatures,
|
|
10450
10484
|
...spanAggregateFeatures,
|
|
10451
10485
|
...threadQueryFeatures
|
|
@@ -10472,6 +10506,7 @@ var ObservabilityStorageClickhouseVNext = class extends _mastra_core_storage.Obs
|
|
|
10472
10506
|
"trace-query-root-span-fields",
|
|
10473
10507
|
"trace-query-root-entity-id",
|
|
10474
10508
|
"trace-aggregate",
|
|
10509
|
+
...aggregateTimeToFirstFeatures,
|
|
10475
10510
|
...spanQueryFeatures,
|
|
10476
10511
|
...spanAggregateFeatures,
|
|
10477
10512
|
...threadQueryFeatures
|