@lunora/observability 1.0.0-alpha.137 → 1.0.0-alpha.139
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/index.d.mts +38 -2
- package/dist/index.d.ts +38 -2
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/FUNCTION_METRICS_BUCKETS_TABLE-CHV71isV.mjs +56 -0
- package/dist/packem_shared/{readQueryInsights-DkQfxGfP.mjs → latencyBucketIndex--kZoW0vc.mjs} +1 -1
- package/package.json +2 -2
- package/dist/packem_shared/FUNCTION_METRICS_BUCKETS_TABLE-ChlIe0vF.mjs +0 -56
package/dist/index.d.mts
CHANGED
|
@@ -1081,8 +1081,15 @@ interface FunctionMetricIndexHit {
|
|
|
1081
1081
|
/** The table the index is declared on. */
|
|
1082
1082
|
table: string;
|
|
1083
1083
|
}
|
|
1084
|
-
/**
|
|
1084
|
+
/**
|
|
1085
|
+
* Fields recorded for one completed dispatch, or for a coalesced delta of
|
|
1086
|
+
* several. `errored` advances the failure counters. The optional count-carrying
|
|
1087
|
+
* fields let a caller that batched N dispatches write their exact sum in one
|
|
1088
|
+
* upsert; omitted, every field defaults to the single-dispatch value.
|
|
1089
|
+
*/
|
|
1085
1090
|
interface RecordFunctionMetricInput {
|
|
1091
|
+
/** Dispatches this record stands for. Default `1`. */
|
|
1092
|
+
calls?: number;
|
|
1086
1093
|
/**
|
|
1087
1094
|
* Whether the dispatch failed on an optimistic-concurrency (OCC) write
|
|
1088
1095
|
* conflict — a compare-and-swap that lost to a concurrent commit. Advances
|
|
@@ -1091,12 +1098,29 @@ interface RecordFunctionMetricInput {
|
|
|
1091
1098
|
* Omitted/false on the common path, keeping the hot path unchanged.
|
|
1092
1099
|
*/
|
|
1093
1100
|
conflicted?: boolean;
|
|
1101
|
+
/** Conflicts in a coalesced delta. Default `conflicted ? 1 : 0`. */
|
|
1102
|
+
conflicts?: number;
|
|
1103
|
+
/** Longest handler time in a coalesced delta. Default `durationMs`. */
|
|
1104
|
+
durationMaxMs?: number;
|
|
1105
|
+
/** Shortest handler time in a coalesced delta. Default `durationMs`. */
|
|
1106
|
+
durationMinMs?: number;
|
|
1094
1107
|
/** Wall-clock millis the handler took. */
|
|
1095
1108
|
durationMs: number;
|
|
1109
|
+
/** Summed handler time of a coalesced delta. Default `durationMs`. */
|
|
1110
|
+
durationTotalMs?: number;
|
|
1096
1111
|
/** Whether the dispatch threw. */
|
|
1097
1112
|
errored: boolean;
|
|
1098
1113
|
/** Most recent failure message, recorded only when `errored`. */
|
|
1099
1114
|
errorMessage?: string;
|
|
1115
|
+
/** Failed dispatches in a coalesced delta. Default `errored ? 1 : 0`. */
|
|
1116
|
+
errors?: number;
|
|
1117
|
+
/**
|
|
1118
|
+
* Per-`(table, index)` hit counts of a coalesced delta (one per dispatch that
|
|
1119
|
+
* used the index). When set, replaces {@link RecordFunctionMetricInput.indexHits}.
|
|
1120
|
+
*/
|
|
1121
|
+
indexHitCounts?: ReadonlyArray<IndexHit & {
|
|
1122
|
+
count: number;
|
|
1123
|
+
}>;
|
|
1100
1124
|
/**
|
|
1101
1125
|
* Distinct declared indexes this dispatch exercised (used to narrow a read),
|
|
1102
1126
|
* collected from the `onIndexUse` signal. Each entry bumps the
|
|
@@ -1105,8 +1129,18 @@ interface RecordFunctionMetricInput {
|
|
|
1105
1129
|
* dispatch used no declared index, keeping the hot path unchanged.
|
|
1106
1130
|
*/
|
|
1107
1131
|
indexHits?: ReadonlyArray<IndexHit>;
|
|
1132
|
+
/** Epoch-ms of the latest failure in a coalesced delta. Default `errored ? ts : null`. */
|
|
1133
|
+
lastErrorAt?: number | null;
|
|
1108
1134
|
/** The `<file>:<function>` identifier. */
|
|
1109
1135
|
path: string;
|
|
1136
|
+
/**
|
|
1137
|
+
* Per-table full-scan counts of a coalesced delta (one per dispatch that
|
|
1138
|
+
* scanned the table). When set, replaces {@link RecordFunctionMetricInput.scannedTables}.
|
|
1139
|
+
*/
|
|
1140
|
+
scanCounts?: ReadonlyArray<{
|
|
1141
|
+
count: number;
|
|
1142
|
+
table: string;
|
|
1143
|
+
}>;
|
|
1110
1144
|
/**
|
|
1111
1145
|
* Distinct tables this dispatch full-scanned (read with no index / point
|
|
1112
1146
|
* lookup), collected from the `SCAN_DEP` reads. Each entry bumps the
|
|
@@ -1614,6 +1648,8 @@ interface QueryStatEntry {
|
|
|
1614
1648
|
/** Total wall-clock milliseconds across all executions. */
|
|
1615
1649
|
totalDurationMs: number;
|
|
1616
1650
|
}
|
|
1651
|
+
/** Index of the first histogram edge at or above `durationMs`; the last index is the overflow bucket. */
|
|
1652
|
+
declare const latencyBucketIndex: (durationMs: number) => number;
|
|
1617
1653
|
/** One statement's activity within a chosen time range. */
|
|
1618
1654
|
interface QueryInsightEntry {
|
|
1619
1655
|
/** Mean milliseconds per execution across the range. */
|
|
@@ -2305,4 +2341,4 @@ type AuthMetricsBucket, type ContextFetch, type ContextLogLevel, type ContextMet
|
|
|
2305
2341
|
* mistake `@lunora/do`'s own barrel documents having made once with the search
|
|
2306
2342
|
* core. What is exported here is what a consumer actually needs.
|
|
2307
2343
|
*/
|
|
2308
|
-
type RecordAuthEventInput, type RecordFunctionMetricInput, type RequestLogEntry, type RequestLogResult, type RequestLogWriteOptions, type RequestOutcome, type SecurityAuditResult, type SecurityFinding, type SecurityFindingKind, type SecurityFindingLevel, SpanBuffer, type SpanCollection, type SpanCollector, type SpanEvent, type SpanEventPoint, type SpanHandle, type OtlpSpanKind as SpanKind, type SpanLink, type SpanOptions, type SqlClientLike, type TallySurface, type TraceAnchor, type TraceSpan, type TraceSummary, type TracedFetchDeps, type TracerDeps, appendRequestLogEntry, applyHostRootSpan, buildSecurityAudit, createDatabaseTally, createMetrics, createSpanCollector, createTracedFetch, createTracer, dispatchRootSpan, emitLogEvent, emitRequestLogEvent, ensureAuthMetricsTables, ensureFunctionMetricsTables, ensureRequestLogTable, explainIssue, findDanglingReferences, foldTraces, formatTally, instrumentDatabase, instrumentSqlClient, mergeScanAttribution, parseExplainIssueArgs, parseLogArgs, readAuthMetrics, readErrorIssues, readFunctionMetricBuckets, readFunctionMetricIndexHits, readFunctionMetricScans, readFunctionMetrics, readFunctionMetricsTotals, readMetricHistory, readQueryInsights, readQueryMetrics, readRequestLog, recordAuthEvent, recordFunctionMetric, recordMetricHistory, recordQueryMetric, redactArgs, resolveTraceAnchor, setHostSpanAttributes, upsertIssueState };
|
|
2344
|
+
type RecordAuthEventInput, type RecordFunctionMetricInput, type RequestLogEntry, type RequestLogResult, type RequestLogWriteOptions, type RequestOutcome, type SecurityAuditResult, type SecurityFinding, type SecurityFindingKind, type SecurityFindingLevel, SpanBuffer, type SpanCollection, type SpanCollector, type SpanEvent, type SpanEventPoint, type SpanHandle, type OtlpSpanKind as SpanKind, type SpanLink, type SpanOptions, type SqlClientLike, type TallySurface, type TraceAnchor, type TraceSpan, type TraceSummary, type TracedFetchDeps, type TracerDeps, appendRequestLogEntry, applyHostRootSpan, buildSecurityAudit, createDatabaseTally, createMetrics, createSpanCollector, createTracedFetch, createTracer, dispatchRootSpan, emitLogEvent, emitRequestLogEvent, ensureAuthMetricsTables, ensureFunctionMetricsTables, ensureRequestLogTable, explainIssue, findDanglingReferences, foldTraces, formatTally, instrumentDatabase, instrumentSqlClient, latencyBucketIndex, mergeScanAttribution, parseExplainIssueArgs, parseLogArgs, readAuthMetrics, readErrorIssues, readFunctionMetricBuckets, readFunctionMetricIndexHits, readFunctionMetricScans, readFunctionMetrics, readFunctionMetricsTotals, readMetricHistory, readQueryInsights, readQueryMetrics, readRequestLog, recordAuthEvent, recordFunctionMetric, recordMetricHistory, recordQueryMetric, redactArgs, resolveTraceAnchor, setHostSpanAttributes, upsertIssueState };
|
package/dist/index.d.ts
CHANGED
|
@@ -1081,8 +1081,15 @@ interface FunctionMetricIndexHit {
|
|
|
1081
1081
|
/** The table the index is declared on. */
|
|
1082
1082
|
table: string;
|
|
1083
1083
|
}
|
|
1084
|
-
/**
|
|
1084
|
+
/**
|
|
1085
|
+
* Fields recorded for one completed dispatch, or for a coalesced delta of
|
|
1086
|
+
* several. `errored` advances the failure counters. The optional count-carrying
|
|
1087
|
+
* fields let a caller that batched N dispatches write their exact sum in one
|
|
1088
|
+
* upsert; omitted, every field defaults to the single-dispatch value.
|
|
1089
|
+
*/
|
|
1085
1090
|
interface RecordFunctionMetricInput {
|
|
1091
|
+
/** Dispatches this record stands for. Default `1`. */
|
|
1092
|
+
calls?: number;
|
|
1086
1093
|
/**
|
|
1087
1094
|
* Whether the dispatch failed on an optimistic-concurrency (OCC) write
|
|
1088
1095
|
* conflict — a compare-and-swap that lost to a concurrent commit. Advances
|
|
@@ -1091,12 +1098,29 @@ interface RecordFunctionMetricInput {
|
|
|
1091
1098
|
* Omitted/false on the common path, keeping the hot path unchanged.
|
|
1092
1099
|
*/
|
|
1093
1100
|
conflicted?: boolean;
|
|
1101
|
+
/** Conflicts in a coalesced delta. Default `conflicted ? 1 : 0`. */
|
|
1102
|
+
conflicts?: number;
|
|
1103
|
+
/** Longest handler time in a coalesced delta. Default `durationMs`. */
|
|
1104
|
+
durationMaxMs?: number;
|
|
1105
|
+
/** Shortest handler time in a coalesced delta. Default `durationMs`. */
|
|
1106
|
+
durationMinMs?: number;
|
|
1094
1107
|
/** Wall-clock millis the handler took. */
|
|
1095
1108
|
durationMs: number;
|
|
1109
|
+
/** Summed handler time of a coalesced delta. Default `durationMs`. */
|
|
1110
|
+
durationTotalMs?: number;
|
|
1096
1111
|
/** Whether the dispatch threw. */
|
|
1097
1112
|
errored: boolean;
|
|
1098
1113
|
/** Most recent failure message, recorded only when `errored`. */
|
|
1099
1114
|
errorMessage?: string;
|
|
1115
|
+
/** Failed dispatches in a coalesced delta. Default `errored ? 1 : 0`. */
|
|
1116
|
+
errors?: number;
|
|
1117
|
+
/**
|
|
1118
|
+
* Per-`(table, index)` hit counts of a coalesced delta (one per dispatch that
|
|
1119
|
+
* used the index). When set, replaces {@link RecordFunctionMetricInput.indexHits}.
|
|
1120
|
+
*/
|
|
1121
|
+
indexHitCounts?: ReadonlyArray<IndexHit & {
|
|
1122
|
+
count: number;
|
|
1123
|
+
}>;
|
|
1100
1124
|
/**
|
|
1101
1125
|
* Distinct declared indexes this dispatch exercised (used to narrow a read),
|
|
1102
1126
|
* collected from the `onIndexUse` signal. Each entry bumps the
|
|
@@ -1105,8 +1129,18 @@ interface RecordFunctionMetricInput {
|
|
|
1105
1129
|
* dispatch used no declared index, keeping the hot path unchanged.
|
|
1106
1130
|
*/
|
|
1107
1131
|
indexHits?: ReadonlyArray<IndexHit>;
|
|
1132
|
+
/** Epoch-ms of the latest failure in a coalesced delta. Default `errored ? ts : null`. */
|
|
1133
|
+
lastErrorAt?: number | null;
|
|
1108
1134
|
/** The `<file>:<function>` identifier. */
|
|
1109
1135
|
path: string;
|
|
1136
|
+
/**
|
|
1137
|
+
* Per-table full-scan counts of a coalesced delta (one per dispatch that
|
|
1138
|
+
* scanned the table). When set, replaces {@link RecordFunctionMetricInput.scannedTables}.
|
|
1139
|
+
*/
|
|
1140
|
+
scanCounts?: ReadonlyArray<{
|
|
1141
|
+
count: number;
|
|
1142
|
+
table: string;
|
|
1143
|
+
}>;
|
|
1110
1144
|
/**
|
|
1111
1145
|
* Distinct tables this dispatch full-scanned (read with no index / point
|
|
1112
1146
|
* lookup), collected from the `SCAN_DEP` reads. Each entry bumps the
|
|
@@ -1614,6 +1648,8 @@ interface QueryStatEntry {
|
|
|
1614
1648
|
/** Total wall-clock milliseconds across all executions. */
|
|
1615
1649
|
totalDurationMs: number;
|
|
1616
1650
|
}
|
|
1651
|
+
/** Index of the first histogram edge at or above `durationMs`; the last index is the overflow bucket. */
|
|
1652
|
+
declare const latencyBucketIndex: (durationMs: number) => number;
|
|
1617
1653
|
/** One statement's activity within a chosen time range. */
|
|
1618
1654
|
interface QueryInsightEntry {
|
|
1619
1655
|
/** Mean milliseconds per execution across the range. */
|
|
@@ -2305,4 +2341,4 @@ type AuthMetricsBucket, type ContextFetch, type ContextLogLevel, type ContextMet
|
|
|
2305
2341
|
* mistake `@lunora/do`'s own barrel documents having made once with the search
|
|
2306
2342
|
* core. What is exported here is what a consumer actually needs.
|
|
2307
2343
|
*/
|
|
2308
|
-
type RecordAuthEventInput, type RecordFunctionMetricInput, type RequestLogEntry, type RequestLogResult, type RequestLogWriteOptions, type RequestOutcome, type SecurityAuditResult, type SecurityFinding, type SecurityFindingKind, type SecurityFindingLevel, SpanBuffer, type SpanCollection, type SpanCollector, type SpanEvent, type SpanEventPoint, type SpanHandle, type OtlpSpanKind as SpanKind, type SpanLink, type SpanOptions, type SqlClientLike, type TallySurface, type TraceAnchor, type TraceSpan, type TraceSummary, type TracedFetchDeps, type TracerDeps, appendRequestLogEntry, applyHostRootSpan, buildSecurityAudit, createDatabaseTally, createMetrics, createSpanCollector, createTracedFetch, createTracer, dispatchRootSpan, emitLogEvent, emitRequestLogEvent, ensureAuthMetricsTables, ensureFunctionMetricsTables, ensureRequestLogTable, explainIssue, findDanglingReferences, foldTraces, formatTally, instrumentDatabase, instrumentSqlClient, mergeScanAttribution, parseExplainIssueArgs, parseLogArgs, readAuthMetrics, readErrorIssues, readFunctionMetricBuckets, readFunctionMetricIndexHits, readFunctionMetricScans, readFunctionMetrics, readFunctionMetricsTotals, readMetricHistory, readQueryInsights, readQueryMetrics, readRequestLog, recordAuthEvent, recordFunctionMetric, recordMetricHistory, recordQueryMetric, redactArgs, resolveTraceAnchor, setHostSpanAttributes, upsertIssueState };
|
|
2344
|
+
type RecordAuthEventInput, type RecordFunctionMetricInput, type RequestLogEntry, type RequestLogResult, type RequestLogWriteOptions, type RequestOutcome, type SecurityAuditResult, type SecurityFinding, type SecurityFindingKind, type SecurityFindingLevel, SpanBuffer, type SpanCollection, type SpanCollector, type SpanEvent, type SpanEventPoint, type SpanHandle, type OtlpSpanKind as SpanKind, type SpanLink, type SpanOptions, type SqlClientLike, type TallySurface, type TraceAnchor, type TraceSpan, type TraceSummary, type TracedFetchDeps, type TracerDeps, appendRequestLogEntry, applyHostRootSpan, buildSecurityAudit, createDatabaseTally, createMetrics, createSpanCollector, createTracedFetch, createTracer, dispatchRootSpan, emitLogEvent, emitRequestLogEvent, ensureAuthMetricsTables, ensureFunctionMetricsTables, ensureRequestLogTable, explainIssue, findDanglingReferences, foldTraces, formatTally, instrumentDatabase, instrumentSqlClient, latencyBucketIndex, mergeScanAttribution, parseExplainIssueArgs, parseLogArgs, readAuthMetrics, readErrorIssues, readFunctionMetricBuckets, readFunctionMetricIndexHits, readFunctionMetricScans, readFunctionMetrics, readFunctionMetricsTotals, readMetricHistory, readQueryInsights, readQueryMetrics, readRequestLog, recordAuthEvent, recordFunctionMetric, recordMetricHistory, recordQueryMetric, redactArgs, resolveTraceAnchor, setHostSpanAttributes, upsertIssueState };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AUTH_METRICS_BUCKETS_TABLE as t,AUTH_METRICS_BUCKET_MS as o,AUTH_METRICS_BUCKET_RETENTION as T,AUTH_METRICS_TABLE as a,ensureAuthMetricsTables as s,readAuthMetrics as E,recordAuthEvent as _}from"./packem_shared/AUTH_METRICS_BUCKETS_TABLE-C-qbQA-w.mjs";import{createMetrics as
|
|
1
|
+
import{AUTH_METRICS_BUCKETS_TABLE as t,AUTH_METRICS_BUCKET_MS as o,AUTH_METRICS_BUCKET_RETENTION as T,AUTH_METRICS_TABLE as a,ensureAuthMetricsTables as s,readAuthMetrics as E,recordAuthEvent as _}from"./packem_shared/AUTH_METRICS_BUCKETS_TABLE-C-qbQA-w.mjs";import{createMetrics as n,createSpanCollector as S,createTracedFetch as i,createTracer as I,dispatchRootSpan as u}from"./packem_shared/createMetrics-D8wcdkye.mjs";import{createDatabaseTally as p,formatTally as A,instrumentDatabase as C,instrumentSqlClient as N}from"./packem_shared/createDatabaseTally-mUypNATC.mjs";import{FUNCTION_METRICS_BUCKETS_TABLE as d,FUNCTION_METRICS_BUCKET_MS as R,FUNCTION_METRICS_BUCKET_RETENTION as U,FUNCTION_METRICS_INDEX_TABLE as m,FUNCTION_METRICS_MAX_PATHS as L,FUNCTION_METRICS_READ_LIMIT as l,FUNCTION_METRICS_SCANS_TABLE as x,FUNCTION_METRICS_TABLE as B,ensureFunctionMetricsTables as F,mergeScanAttribution as g,readFunctionMetricBuckets as H,readFunctionMetricIndexHits as O,readFunctionMetricScans as y,readFunctionMetrics as b,readFunctionMetricsTotals as D,recordFunctionMetric as h}from"./packem_shared/FUNCTION_METRICS_BUCKETS_TABLE-CHV71isV.mjs";import{applyHostRootSpan as q,setHostSpanAttributes as v}from"./packem_shared/applyHostRootSpan-DToRfMn8.mjs";import{DEFAULT_EXPLAIN_ISSUE_MODEL as G,explainIssue as X,parseExplainIssueArgs as k}from"./packem_shared/DEFAULT_EXPLAIN_ISSUE_MODEL-BkFTgdkd.mjs";import{ISSUE_SEVERITIES as V,ISSUE_STATE_TABLE as j,ISSUE_STATUSES as w,upsertIssueState as z}from"./packem_shared/ISSUE_SEVERITIES-0SJ0glV4.mjs";import{LogBuffer as W}from"./packem_shared/LogBuffer-BmD4CfV0.mjs";import{M as Z}from"./packem_shared/metric-buffer-Bx0XbypU.mjs";import{readMetricHistory as ee,recordMetricHistory as re}from"./packem_shared/readMetricHistory-TKfnwFNv.mjs";import{latencyBucketIndex as oe,readQueryInsights as Te,readQueryMetrics as ae,recordQueryMetric as se}from"./packem_shared/latencyBucketIndex--kZoW0vc.mjs";import{R as _e,a as ce,e as ne,b as Se,c as ie,p as Ie,r as ue,d as Me,f as pe}from"./packem_shared/request-log-YtJxmSWX.mjs";import{MIN_ADMIN_TOKEN_LENGTH as Ce,MIN_AUTH_SECRET_LENGTH as Ne,buildSecurityAudit as fe}from"./packem_shared/MIN_ADMIN_TOKEN_LENGTH-DSOQ6rno.mjs";import{SpanBuffer as Re,foldTraces as Ue}from"./packem_shared/SpanBuffer-DnYOc8uk.mjs";import{findDanglingReferences as Le}from"./packem_shared/findDanglingReferences-BaOyIdxz.mjs";import{resolveTraceAnchor as xe}from"./packem_shared/resolveTraceAnchor-DDAPZRBB.mjs";export{t as AUTH_METRICS_BUCKETS_TABLE,o as AUTH_METRICS_BUCKET_MS,T as AUTH_METRICS_BUCKET_RETENTION,a as AUTH_METRICS_TABLE,G as DEFAULT_EXPLAIN_ISSUE_MODEL,d as FUNCTION_METRICS_BUCKETS_TABLE,R as FUNCTION_METRICS_BUCKET_MS,U as FUNCTION_METRICS_BUCKET_RETENTION,m as FUNCTION_METRICS_INDEX_TABLE,L as FUNCTION_METRICS_MAX_PATHS,l as FUNCTION_METRICS_READ_LIMIT,x as FUNCTION_METRICS_SCANS_TABLE,B as FUNCTION_METRICS_TABLE,V as ISSUE_SEVERITIES,j as ISSUE_STATE_TABLE,w as ISSUE_STATUSES,W as LogBuffer,Ce as MIN_ADMIN_TOKEN_LENGTH,Ne as MIN_AUTH_SECRET_LENGTH,Z as MetricBuffer,_e as REQUEST_LOG_TABLE,Re as SpanBuffer,ce as appendRequestLogEntry,q as applyHostRootSpan,fe as buildSecurityAudit,p as createDatabaseTally,n as createMetrics,S as createSpanCollector,i as createTracedFetch,I as createTracer,u as dispatchRootSpan,ne as emitLogEvent,Se as emitRequestLogEvent,s as ensureAuthMetricsTables,F as ensureFunctionMetricsTables,ie as ensureRequestLogTable,X as explainIssue,Le as findDanglingReferences,Ue as foldTraces,A as formatTally,C as instrumentDatabase,N as instrumentSqlClient,oe as latencyBucketIndex,g as mergeScanAttribution,k as parseExplainIssueArgs,Ie as parseLogArgs,E as readAuthMetrics,ue as readErrorIssues,H as readFunctionMetricBuckets,O as readFunctionMetricIndexHits,y as readFunctionMetricScans,b as readFunctionMetrics,D as readFunctionMetricsTotals,ee as readMetricHistory,Te as readQueryInsights,ae as readQueryMetrics,Me as readRequestLog,_ as recordAuthEvent,h as recordFunctionMetric,re as recordMetricHistory,se as recordQueryMetric,pe as redactArgs,xe as resolveTraceAnchor,v as setHostSpanAttributes,z as upsertIssueState};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import{s as b}from"./prune-marker-B4An9Nuj.mjs";import{r}from"./run-sql-0aPgJkIw.mjs";const E="__lunora_metrics",T="__lunora_metrics_buckets",N="__lunora_metrics_scans",L="__lunora_metrics_index",u=6e4,x=1440,I=5e3,l=1e3,D=e=>Math.floor(e/u)*u,f=e=>{const t=new Map;for(const a of e)t.set(`${a.table}\0${a.index}`,{index:a.index,table:a.table});return[...t.values()]},S=new WeakSet,_=e=>{if(!S.has(e)){r(e,`CREATE TABLE IF NOT EXISTS "${E}" (
|
|
2
|
+
path TEXT PRIMARY KEY,
|
|
3
|
+
calls INTEGER NOT NULL DEFAULT 0,
|
|
4
|
+
errors INTEGER NOT NULL DEFAULT 0,
|
|
5
|
+
conflicts INTEGER NOT NULL DEFAULT 0,
|
|
6
|
+
scans INTEGER NOT NULL DEFAULT 0,
|
|
7
|
+
total_duration_ms REAL NOT NULL DEFAULT 0,
|
|
8
|
+
min_duration_ms REAL,
|
|
9
|
+
max_duration_ms REAL NOT NULL DEFAULT 0,
|
|
10
|
+
last_called_at REAL NOT NULL DEFAULT 0,
|
|
11
|
+
last_error_at REAL,
|
|
12
|
+
last_error_message TEXT
|
|
13
|
+
)`);for(const t of["scans","conflicts"])try{r(e,`ALTER TABLE "${E}" ADD COLUMN ${t} INTEGER NOT NULL DEFAULT 0`)}catch{}r(e,`CREATE TABLE IF NOT EXISTS "${T}" (
|
|
14
|
+
path TEXT NOT NULL,
|
|
15
|
+
bucket_ms INTEGER NOT NULL,
|
|
16
|
+
calls INTEGER NOT NULL DEFAULT 0,
|
|
17
|
+
errors INTEGER NOT NULL DEFAULT 0,
|
|
18
|
+
PRIMARY KEY (path, bucket_ms)
|
|
19
|
+
)`),r(e,`CREATE TABLE IF NOT EXISTS "${N}" (
|
|
20
|
+
path TEXT NOT NULL,
|
|
21
|
+
table_name TEXT NOT NULL,
|
|
22
|
+
scans INTEGER NOT NULL DEFAULT 0,
|
|
23
|
+
PRIMARY KEY (path, table_name)
|
|
24
|
+
)`),r(e,`CREATE TABLE IF NOT EXISTS "${L}" (
|
|
25
|
+
table_name TEXT NOT NULL,
|
|
26
|
+
index_name TEXT NOT NULL,
|
|
27
|
+
reads INTEGER NOT NULL DEFAULT 0,
|
|
28
|
+
PRIMARY KEY (table_name, index_name)
|
|
29
|
+
)`),S.add(e)}},R=new WeakMap,$=e=>{let t=R.get(e);return t===void 0&&(t=new Set,R.set(e,t)),t},k=(e,t)=>{const a=$(e);return a.has(t)?!0:r(e,`SELECT 1 AS c FROM "${E}" WHERE path = ? LIMIT 1`,t).toArray().length>0?(a.add(t),!0):r(e,`SELECT COUNT(*) AS n FROM "${E}"`).one().n>=I?!1:(a.add(t),!0)},H=(e,t)=>{if(_(e),!k(e,t.path))return;const a=t.scanCounts??[...new Set(t.scannedTables)].map(n=>({count:1,table:n})),s=a.reduce((n,d)=>n+d.count,0),c=t.indexHitCounts??f(t.indexHits??[]).map(n=>({...n,count:1})),o=t.calls??1,m=t.errors??(t.errored?1:0),C=t.conflicts??(t.conflicted?1:0),O=t.durationTotalMs??t.durationMs,M=t.durationMinMs??t.durationMs,U=t.durationMaxMs??t.durationMs,h=t.errored?t.ts:null,i=t.lastErrorAt===void 0?h:t.lastErrorAt,F=i===null?null:t.errorMessage??null;r(e,`INSERT INTO "${E}"
|
|
30
|
+
(path, calls, errors, conflicts, scans, total_duration_ms, min_duration_ms, max_duration_ms, last_called_at, last_error_at, last_error_message)
|
|
31
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
32
|
+
ON CONFLICT(path) DO UPDATE SET
|
|
33
|
+
calls = calls + excluded.calls,
|
|
34
|
+
errors = errors + excluded.errors,
|
|
35
|
+
conflicts = conflicts + excluded.conflicts,
|
|
36
|
+
scans = scans + excluded.scans,
|
|
37
|
+
total_duration_ms = total_duration_ms + excluded.total_duration_ms,
|
|
38
|
+
min_duration_ms = MIN(COALESCE(min_duration_ms, excluded.min_duration_ms), excluded.min_duration_ms),
|
|
39
|
+
max_duration_ms = MAX(max_duration_ms, excluded.max_duration_ms),
|
|
40
|
+
last_called_at = excluded.last_called_at,
|
|
41
|
+
last_error_at = CASE WHEN excluded.last_error_at IS NULL THEN last_error_at ELSE excluded.last_error_at END,
|
|
42
|
+
last_error_message = CASE WHEN excluded.last_error_at IS NULL THEN last_error_message ELSE excluded.last_error_message END`,t.path,o,m,C,s,O,M,U,t.ts,i,F);const A=D(t.ts);r(e,`INSERT INTO "${T}" (path, bucket_ms, calls, errors)
|
|
43
|
+
VALUES (?, ?, ?, ?)
|
|
44
|
+
ON CONFLICT(path, bucket_ms) DO UPDATE SET
|
|
45
|
+
calls = calls + excluded.calls,
|
|
46
|
+
errors = errors + excluded.errors`,t.path,A,o,m),b(e,A,t.path)&&r(e,`DELETE FROM "${T}"
|
|
47
|
+
WHERE path = ?
|
|
48
|
+
AND bucket_ms <= (
|
|
49
|
+
SELECT MAX(bucket_ms) - ? FROM "${T}" WHERE path = ?
|
|
50
|
+
)`,t.path,x*u,t.path);for(const{count:n,table:d}of a)r(e,`INSERT INTO "${N}" (path, table_name, scans)
|
|
51
|
+
VALUES (?, ?, ?)
|
|
52
|
+
ON CONFLICT(path, table_name) DO UPDATE SET
|
|
53
|
+
scans = scans + excluded.scans`,t.path,d,n);for(const n of c)r(e,`INSERT INTO "${L}" (table_name, index_name, reads)
|
|
54
|
+
VALUES (?, ?, ?)
|
|
55
|
+
ON CONFLICT(table_name, index_name) DO UPDATE SET
|
|
56
|
+
reads = reads + excluded.reads`,n.table,n.index,n.count)},p=e=>{_(e);const t=r(e,`SELECT path, table_name, scans FROM "${N}" ORDER BY scans DESC, path ASC, table_name ASC LIMIT ${String(l)}`).toArray(),a=new Map;for(const s of t){const c=a.get(s.path),o={scans:s.scans,table:s.table_name};c===void 0?a.set(s.path,[o]):c.push(o)}return a},P=e=>(_(e),r(e,`SELECT table_name, index_name, reads FROM "${L}" ORDER BY table_name ASC, index_name ASC LIMIT ${String(l)}`).toArray().map(a=>({index:a.index_name,reads:a.reads,table:a.table_name}))),X=(e,t)=>{for(const a of t){const s=e.find(c=>c.table===a);s===void 0?e.push({scans:1,table:a}):s.scans+=1}return e.sort((a,s)=>s.scans-a.scans||a.table.localeCompare(s.table)),e},y=e=>{_(e);const t=p(e);return r(e,`SELECT * FROM "${E}" ORDER BY last_called_at DESC LIMIT ${String(l)}`).toArray().map(s=>({calls:s.calls,conflicts:s.conflicts,errors:s.errors,lastCalledAt:s.last_called_at,lastErrorAt:s.last_error_at,lastErrorMessage:s.last_error_message,maxDurationMs:s.max_duration_ms,path:s.path,scannedTables:t.get(s.path)??[],scans:s.scans,totalDurationMs:s.total_duration_ms}))},Y=(e,t)=>{_(e);const a=t===void 0?r(e,`SELECT path, bucket_ms, calls, errors FROM "${T}" ORDER BY bucket_ms DESC, path ASC LIMIT ${String(l+1)}`).toArray():r(e,`SELECT path, bucket_ms, calls, errors FROM "${T}" WHERE path = ? ORDER BY bucket_ms DESC LIMIT ${String(l+1)}`,t).toArray(),s=a.length>l;return{buckets:(s?a.slice(0,l):a).toReversed().map(o=>({bucketMs:o.bucket_ms,calls:o.calls,errors:o.errors,path:o.path})),truncated:s}},G=e=>{_(e);const t=r(e,`SELECT SUM(calls) AS requests, SUM(errors) AS errors FROM "${E}"`).one();return{capped:r(e,`SELECT COUNT(*) AS n FROM "${E}"`).one().n>=I,errors:t.errors??0,requests:t.requests??0}};export{T as FUNCTION_METRICS_BUCKETS_TABLE,u as FUNCTION_METRICS_BUCKET_MS,x as FUNCTION_METRICS_BUCKET_RETENTION,L as FUNCTION_METRICS_INDEX_TABLE,I as FUNCTION_METRICS_MAX_PATHS,l as FUNCTION_METRICS_READ_LIMIT,N as FUNCTION_METRICS_SCANS_TABLE,E as FUNCTION_METRICS_TABLE,_ as ensureFunctionMetricsTables,X as mergeScanAttribution,Y as readFunctionMetricBuckets,P as readFunctionMetricIndexHits,p as readFunctionMetricScans,y as readFunctionMetrics,G as readFunctionMetricsTotals,H as recordFunctionMetric};
|
package/dist/packem_shared/{readQueryInsights-DkQfxGfP.mjs → latencyBucketIndex--kZoW0vc.mjs}
RENAMED
|
@@ -29,4 +29,4 @@ import{r as a}from"./run-sql-0aPgJkIw.mjs";const F=2166136261,b=16777619,C=(t,e=
|
|
|
29
29
|
exec_count = exec_count + excluded.exec_count,
|
|
30
30
|
total_duration_ms = total_duration_ms + excluded.total_duration_ms,
|
|
31
31
|
rows_read = rows_read + excluded.rows_read,
|
|
32
|
-
rows_written = rows_written + excluded.rows_written`;a(t,l,u,s,r,o,_),Y(t,u,r,o,_,c,s)},K=t=>(w(t),a(t,`SELECT normalized_sql, exec_count, total_duration_ms, rows_read, rows_written FROM "${i}" ORDER BY total_duration_ms DESC`).toArray().map(r=>({execCount:r.exec_count,normalizedSql:r.normalized_sql,rowsRead:r.rows_read,rowsWritten:r.rows_written,totalDurationMs:r.total_duration_ms})));export{$ as QUERY_BUCKET_RETENTION,U as QUERY_METRICS_MAX_SQL_LEN,I as QUERY_METRICS_MAX_STATEMENTS,i as QUERY_METRICS_TABLE,p as normalizeSql,B as pruneQueryBuckets,H as readQueryInsights,K as readQueryMetrics,P as recordQueryMetric};
|
|
32
|
+
rows_written = rows_written + excluded.rows_written`;a(t,l,u,s,r,o,_),Y(t,u,r,o,_,c,s)},K=t=>(w(t),a(t,`SELECT normalized_sql, exec_count, total_duration_ms, rows_read, rows_written FROM "${i}" ORDER BY total_duration_ms DESC`).toArray().map(r=>({execCount:r.exec_count,normalizedSql:r.normalized_sql,rowsRead:r.rows_read,rowsWritten:r.rows_written,totalDurationMs:r.total_duration_ms})));export{$ as QUERY_BUCKET_RETENTION,U as QUERY_METRICS_MAX_SQL_LEN,I as QUERY_METRICS_MAX_STATEMENTS,i as QUERY_METRICS_TABLE,y as latencyBucketIndex,p as normalizeSql,B as pruneQueryBuckets,H as readQueryInsights,K as readQueryMetrics,P as recordQueryMetric};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/observability",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.139",
|
|
4
4
|
"description": "Host-neutral telemetry storage and read models for Lunora, backing the Studio's Logs, Traces, Metrics and Issues views",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lunora",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
47
47
|
"@lunora/fingerprint": "1.0.0-alpha.9",
|
|
48
|
-
"@lunora/shard-engine": "1.0.0-alpha.
|
|
48
|
+
"@lunora/shard-engine": "1.0.0-alpha.128",
|
|
49
49
|
"@visulima/redact": "5.0.0"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import{s as C}from"./prune-marker-B4An9Nuj.mjs";import{r}from"./run-sql-0aPgJkIw.mjs";const c="__lunora_metrics",T="__lunora_metrics_buckets",N="__lunora_metrics_scans",L="__lunora_metrics_index",d=6e4,O=1440,S=5e3,E=1e3,M=t=>Math.floor(t/d)*d,U=t=>{const e=new Map;for(const a of t)e.set(`${a.table}\0${a.index}`,{index:a.index,table:a.table});return[...e.values()]},m=new WeakSet,_=t=>{if(!m.has(t)){r(t,`CREATE TABLE IF NOT EXISTS "${c}" (
|
|
2
|
-
path TEXT PRIMARY KEY,
|
|
3
|
-
calls INTEGER NOT NULL DEFAULT 0,
|
|
4
|
-
errors INTEGER NOT NULL DEFAULT 0,
|
|
5
|
-
conflicts INTEGER NOT NULL DEFAULT 0,
|
|
6
|
-
scans INTEGER NOT NULL DEFAULT 0,
|
|
7
|
-
total_duration_ms REAL NOT NULL DEFAULT 0,
|
|
8
|
-
min_duration_ms REAL,
|
|
9
|
-
max_duration_ms REAL NOT NULL DEFAULT 0,
|
|
10
|
-
last_called_at REAL NOT NULL DEFAULT 0,
|
|
11
|
-
last_error_at REAL,
|
|
12
|
-
last_error_message TEXT
|
|
13
|
-
)`);for(const e of["scans","conflicts"])try{r(t,`ALTER TABLE "${c}" ADD COLUMN ${e} INTEGER NOT NULL DEFAULT 0`)}catch{}r(t,`CREATE TABLE IF NOT EXISTS "${T}" (
|
|
14
|
-
path TEXT NOT NULL,
|
|
15
|
-
bucket_ms INTEGER NOT NULL,
|
|
16
|
-
calls INTEGER NOT NULL DEFAULT 0,
|
|
17
|
-
errors INTEGER NOT NULL DEFAULT 0,
|
|
18
|
-
PRIMARY KEY (path, bucket_ms)
|
|
19
|
-
)`),r(t,`CREATE TABLE IF NOT EXISTS "${N}" (
|
|
20
|
-
path TEXT NOT NULL,
|
|
21
|
-
table_name TEXT NOT NULL,
|
|
22
|
-
scans INTEGER NOT NULL DEFAULT 0,
|
|
23
|
-
PRIMARY KEY (path, table_name)
|
|
24
|
-
)`),r(t,`CREATE TABLE IF NOT EXISTS "${L}" (
|
|
25
|
-
table_name TEXT NOT NULL,
|
|
26
|
-
index_name TEXT NOT NULL,
|
|
27
|
-
reads INTEGER NOT NULL DEFAULT 0,
|
|
28
|
-
PRIMARY KEY (table_name, index_name)
|
|
29
|
-
)`),m.add(t)}},i=new WeakMap,h=t=>{let e=i.get(t);return e===void 0&&(e=new Set,i.set(t,e)),e},F=(t,e)=>{const a=h(t);return a.has(e)?!0:r(t,`SELECT 1 AS c FROM "${c}" WHERE path = ? LIMIT 1`,e).toArray().length>0?(a.add(e),!0):r(t,`SELECT COUNT(*) AS n FROM "${c}"`).one().n>=S?!1:(a.add(e),!0)},f=(t,e)=>{if(_(t),!F(t,e.path))return;const a=e.scannedTables?[...new Set(e.scannedTables)]:[],s=a.length,o=U(e.indexHits??[]),n=e.errored?1:0,A=e.conflicted?1:0,R=e.errored?e.ts:null,I=e.errored?e.errorMessage??null:null;r(t,`INSERT INTO "${c}"
|
|
30
|
-
(path, calls, errors, conflicts, scans, total_duration_ms, min_duration_ms, max_duration_ms, last_called_at, last_error_at, last_error_message)
|
|
31
|
-
VALUES (?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
32
|
-
ON CONFLICT(path) DO UPDATE SET
|
|
33
|
-
calls = calls + 1,
|
|
34
|
-
errors = errors + excluded.errors,
|
|
35
|
-
conflicts = conflicts + excluded.conflicts,
|
|
36
|
-
scans = scans + excluded.scans,
|
|
37
|
-
total_duration_ms = total_duration_ms + excluded.total_duration_ms,
|
|
38
|
-
min_duration_ms = MIN(COALESCE(min_duration_ms, excluded.min_duration_ms), excluded.min_duration_ms),
|
|
39
|
-
max_duration_ms = MAX(max_duration_ms, excluded.max_duration_ms),
|
|
40
|
-
last_called_at = excluded.last_called_at,
|
|
41
|
-
last_error_at = CASE WHEN excluded.last_error_at IS NULL THEN last_error_at ELSE excluded.last_error_at END,
|
|
42
|
-
last_error_message = CASE WHEN excluded.last_error_at IS NULL THEN last_error_message ELSE excluded.last_error_message END`,e.path,n,A,s,e.durationMs,e.durationMs,e.durationMs,e.ts,R,I);const u=M(e.ts);r(t,`INSERT INTO "${T}" (path, bucket_ms, calls, errors)
|
|
43
|
-
VALUES (?, ?, 1, ?)
|
|
44
|
-
ON CONFLICT(path, bucket_ms) DO UPDATE SET
|
|
45
|
-
calls = calls + 1,
|
|
46
|
-
errors = errors + excluded.errors`,e.path,u,n),C(t,u,e.path)&&r(t,`DELETE FROM "${T}"
|
|
47
|
-
WHERE path = ?
|
|
48
|
-
AND bucket_ms <= (
|
|
49
|
-
SELECT MAX(bucket_ms) - ? FROM "${T}" WHERE path = ?
|
|
50
|
-
)`,e.path,O*d,e.path);for(const l of a)r(t,`INSERT INTO "${N}" (path, table_name, scans)
|
|
51
|
-
VALUES (?, ?, 1)
|
|
52
|
-
ON CONFLICT(path, table_name) DO UPDATE SET
|
|
53
|
-
scans = scans + 1`,e.path,l);for(const l of o)r(t,`INSERT INTO "${L}" (table_name, index_name, reads)
|
|
54
|
-
VALUES (?, ?, 1)
|
|
55
|
-
ON CONFLICT(table_name, index_name) DO UPDATE SET
|
|
56
|
-
reads = reads + 1`,l.table,l.index)},b=t=>{_(t);const e=r(t,`SELECT path, table_name, scans FROM "${N}" ORDER BY scans DESC, path ASC, table_name ASC LIMIT ${String(E)}`).toArray(),a=new Map;for(const s of e){const o=a.get(s.path),n={scans:s.scans,table:s.table_name};o===void 0?a.set(s.path,[n]):o.push(n)}return a},p=t=>(_(t),r(t,`SELECT table_name, index_name, reads FROM "${L}" ORDER BY table_name ASC, index_name ASC LIMIT ${String(E)}`).toArray().map(a=>({index:a.index_name,reads:a.reads,table:a.table_name}))),$=(t,e)=>{for(const a of e){const s=t.find(o=>o.table===a);s===void 0?t.push({scans:1,table:a}):s.scans+=1}return t.sort((a,s)=>s.scans-a.scans||a.table.localeCompare(s.table)),t},k=t=>{_(t);const e=b(t);return r(t,`SELECT * FROM "${c}" ORDER BY last_called_at DESC LIMIT ${String(E)}`).toArray().map(s=>({calls:s.calls,conflicts:s.conflicts,errors:s.errors,lastCalledAt:s.last_called_at,lastErrorAt:s.last_error_at,lastErrorMessage:s.last_error_message,maxDurationMs:s.max_duration_ms,path:s.path,scannedTables:e.get(s.path)??[],scans:s.scans,totalDurationMs:s.total_duration_ms}))},g=(t,e)=>{_(t);const a=e===void 0?r(t,`SELECT path, bucket_ms, calls, errors FROM "${T}" ORDER BY bucket_ms DESC, path ASC LIMIT ${String(E+1)}`).toArray():r(t,`SELECT path, bucket_ms, calls, errors FROM "${T}" WHERE path = ? ORDER BY bucket_ms DESC LIMIT ${String(E+1)}`,e).toArray(),s=a.length>E;return{buckets:(s?a.slice(0,E):a).toReversed().map(n=>({bucketMs:n.bucket_ms,calls:n.calls,errors:n.errors,path:n.path})),truncated:s}},B=t=>{_(t);const e=r(t,`SELECT SUM(calls) AS requests, SUM(errors) AS errors FROM "${c}"`).one();return{capped:r(t,`SELECT COUNT(*) AS n FROM "${c}"`).one().n>=S,errors:e.errors??0,requests:e.requests??0}};export{T as FUNCTION_METRICS_BUCKETS_TABLE,d as FUNCTION_METRICS_BUCKET_MS,O as FUNCTION_METRICS_BUCKET_RETENTION,L as FUNCTION_METRICS_INDEX_TABLE,S as FUNCTION_METRICS_MAX_PATHS,E as FUNCTION_METRICS_READ_LIMIT,N as FUNCTION_METRICS_SCANS_TABLE,c as FUNCTION_METRICS_TABLE,_ as ensureFunctionMetricsTables,$ as mergeScanAttribution,g as readFunctionMetricBuckets,p as readFunctionMetricIndexHits,b as readFunctionMetricScans,k as readFunctionMetrics,B as readFunctionMetricsTotals,f as recordFunctionMetric};
|