@lunora/observability 1.0.0-alpha.33 → 1.0.0-alpha.34
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 +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/AUTH_METRICS_BUCKETS_TABLE-CeplWoRm.mjs +22 -0
- package/dist/packem_shared/{FUNCTION_METRICS_BUCKETS_TABLE-SKpGN7hQ.mjs → FUNCTION_METRICS_BUCKETS_TABLE-ChlIe0vF.mjs} +9 -9
- package/dist/packem_shared/prune-marker-B4An9Nuj.mjs +1 -0
- package/package.json +2 -2
- package/dist/packem_shared/AUTH_METRICS_BUCKETS_TABLE-DGMchLuo.mjs +0 -22
package/dist/index.d.mts
CHANGED
|
@@ -64,9 +64,9 @@ declare const ensureAuthMetricsTables: (sql: SqlExec) => void;
|
|
|
64
64
|
* `failures` advances only when `outcome === "fail"`. `since_ms` is set once on
|
|
65
65
|
* the first attempt and never moved (so it stays a true first-seen marker).
|
|
66
66
|
*
|
|
67
|
-
* Exactly two `INSERT … ON CONFLICT … DO UPDATE` statements
|
|
68
|
-
*
|
|
69
|
-
* response path without blocking it.
|
|
67
|
+
* Exactly two `INSERT … ON CONFLICT … DO UPDATE` statements, all keyed by
|
|
68
|
+
* primary key, plus a bounded `DELETE` that runs once per bucket window —
|
|
69
|
+
* cheap enough to fire off the auth response path without blocking it.
|
|
70
70
|
*/
|
|
71
71
|
declare const recordAuthEvent: (sql: SqlExec, input: RecordAuthEventInput) => void;
|
|
72
72
|
/**
|
|
@@ -605,7 +605,7 @@ declare const createSpanCollector: (ids: {
|
|
|
605
605
|
*
|
|
606
606
|
* **DO async-context caveat (EXPERIMENTAL, partially workerd-validated).**
|
|
607
607
|
* `tracing.enterSpan` is now confirmed to EXIST and RUN inside a real Durable
|
|
608
|
-
* Object under `@cloudflare/vitest-
|
|
608
|
+
* Object under `@cloudflare/vitest-plugin` (see
|
|
609
609
|
* `__tests__/workerd/context-telemetry-cf-bridge.workerd.test.ts`): it resolves
|
|
610
610
|
* from `cloudflare:workers`, its callback executes and returns the body value
|
|
611
611
|
* without throwing, `span.isTraced` is a real boolean, and — the key additive
|
package/dist/index.d.ts
CHANGED
|
@@ -64,9 +64,9 @@ declare const ensureAuthMetricsTables: (sql: SqlExec) => void;
|
|
|
64
64
|
* `failures` advances only when `outcome === "fail"`. `since_ms` is set once on
|
|
65
65
|
* the first attempt and never moved (so it stays a true first-seen marker).
|
|
66
66
|
*
|
|
67
|
-
* Exactly two `INSERT … ON CONFLICT … DO UPDATE` statements
|
|
68
|
-
*
|
|
69
|
-
* response path without blocking it.
|
|
67
|
+
* Exactly two `INSERT … ON CONFLICT … DO UPDATE` statements, all keyed by
|
|
68
|
+
* primary key, plus a bounded `DELETE` that runs once per bucket window —
|
|
69
|
+
* cheap enough to fire off the auth response path without blocking it.
|
|
70
70
|
*/
|
|
71
71
|
declare const recordAuthEvent: (sql: SqlExec, input: RecordAuthEventInput) => void;
|
|
72
72
|
/**
|
|
@@ -605,7 +605,7 @@ declare const createSpanCollector: (ids: {
|
|
|
605
605
|
*
|
|
606
606
|
* **DO async-context caveat (EXPERIMENTAL, partially workerd-validated).**
|
|
607
607
|
* `tracing.enterSpan` is now confirmed to EXIST and RUN inside a real Durable
|
|
608
|
-
* Object under `@cloudflare/vitest-
|
|
608
|
+
* Object under `@cloudflare/vitest-plugin` (see
|
|
609
609
|
* `__tests__/workerd/context-telemetry-cf-bridge.workerd.test.ts`): it resolves
|
|
610
610
|
* from `cloudflare:workers`, its callback executes and returns the body value
|
|
611
611
|
* without throwing, `span.isTraced` is a real boolean, and — the key additive
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AUTH_METRICS_BUCKETS_TABLE as t,AUTH_METRICS_BUCKET_MS as T,AUTH_METRICS_BUCKET_RETENTION as o,AUTH_METRICS_TABLE as a,ensureAuthMetricsTables as s,readAuthMetrics as E,recordAuthEvent as _}from"./packem_shared/AUTH_METRICS_BUCKETS_TABLE-
|
|
1
|
+
import{AUTH_METRICS_BUCKETS_TABLE as t,AUTH_METRICS_BUCKET_MS as T,AUTH_METRICS_BUCKET_RETENTION as o,AUTH_METRICS_TABLE as a,ensureAuthMetricsTables as s,readAuthMetrics as E,recordAuthEvent as _}from"./packem_shared/AUTH_METRICS_BUCKETS_TABLE-CeplWoRm.mjs";import{createMetrics as S,createSpanCollector as I,createTracedFetch as i,createTracer as n,dispatchRootSpan as M}from"./packem_shared/createMetrics-z5hLfR2P.mjs";import{createDatabaseTally as A,formatTally as C,instrumentDatabase as N}from"./packem_shared/createDatabaseTally-DWEtTj-a.mjs";import{FUNCTION_METRICS_BUCKETS_TABLE as f,FUNCTION_METRICS_BUCKET_MS as U,FUNCTION_METRICS_BUCKET_RETENTION as d,FUNCTION_METRICS_INDEX_TABLE as R,FUNCTION_METRICS_MAX_PATHS as L,FUNCTION_METRICS_READ_LIMIT as m,FUNCTION_METRICS_SCANS_TABLE as x,FUNCTION_METRICS_TABLE as B,ensureFunctionMetricsTables as F,mergeScanAttribution as l,readFunctionMetricBuckets as g,readFunctionMetricIndexHits as O,readFunctionMetricScans as H,readFunctionMetrics as y,readFunctionMetricsTotals as b,recordFunctionMetric as D}from"./packem_shared/FUNCTION_METRICS_BUCKETS_TABLE-ChlIe0vF.mjs";import{DEFAULT_EXPLAIN_ISSUE_MODEL as K,explainIssue as q,parseExplainIssueArgs as v}from"./packem_shared/DEFAULT_EXPLAIN_ISSUE_MODEL-BGGX6k5D.mjs";import{ISSUE_SEVERITIES as G,ISSUE_STATE_TABLE as X,ISSUE_STATUSES as P,upsertIssueState as k}from"./packem_shared/ISSUE_SEVERITIES-gLC4VEPQ.mjs";import{LogBuffer as j}from"./packem_shared/LogBuffer-bIvCelI-.mjs";import{M as z}from"./packem_shared/metric-buffer-QGsa8K4_.mjs";import{readMetricHistory as W,recordMetricHistory as Y}from"./packem_shared/readMetricHistory-dka8wnH-.mjs";import{readQueryInsights as $,readQueryMetrics as ee,recordQueryMetric as re}from"./packem_shared/readQueryInsights-Ev3XWiWk.mjs";import{R as Te,a as oe,e as ae,b as se,c as Ee,p as _e,r as ce,d as Se,f as Ie}from"./packem_shared/request-log-COB2xhns.mjs";import{MIN_ADMIN_TOKEN_LENGTH as ne,MIN_AUTH_SECRET_LENGTH as Me,buildSecurityAudit as ue}from"./packem_shared/MIN_ADMIN_TOKEN_LENGTH-CidkqOQ1.mjs";import{SpanBuffer as Ce,foldTraces as Ne}from"./packem_shared/SpanBuffer-zjqCAuGp.mjs";import{findDanglingReferences as fe}from"./packem_shared/findDanglingReferences-Dxl42LBT.mjs";import{r as de}from"./packem_shared/trace-context-CpFltS-q.mjs";export{t as AUTH_METRICS_BUCKETS_TABLE,T as AUTH_METRICS_BUCKET_MS,o as AUTH_METRICS_BUCKET_RETENTION,a as AUTH_METRICS_TABLE,K as DEFAULT_EXPLAIN_ISSUE_MODEL,f as FUNCTION_METRICS_BUCKETS_TABLE,U as FUNCTION_METRICS_BUCKET_MS,d as FUNCTION_METRICS_BUCKET_RETENTION,R as FUNCTION_METRICS_INDEX_TABLE,L as FUNCTION_METRICS_MAX_PATHS,m as FUNCTION_METRICS_READ_LIMIT,x as FUNCTION_METRICS_SCANS_TABLE,B as FUNCTION_METRICS_TABLE,G as ISSUE_SEVERITIES,X as ISSUE_STATE_TABLE,P as ISSUE_STATUSES,j as LogBuffer,ne as MIN_ADMIN_TOKEN_LENGTH,Me as MIN_AUTH_SECRET_LENGTH,z as MetricBuffer,Te as REQUEST_LOG_TABLE,Ce as SpanBuffer,oe as appendRequestLogEntry,ue as buildSecurityAudit,A as createDatabaseTally,S as createMetrics,I as createSpanCollector,i as createTracedFetch,n as createTracer,M as dispatchRootSpan,ae as emitLogEvent,se as emitRequestLogEvent,s as ensureAuthMetricsTables,F as ensureFunctionMetricsTables,Ee as ensureRequestLogTable,q as explainIssue,fe as findDanglingReferences,Ne as foldTraces,C as formatTally,N as instrumentDatabase,l as mergeScanAttribution,v as parseExplainIssueArgs,_e as parseLogArgs,E as readAuthMetrics,ce as readErrorIssues,g as readFunctionMetricBuckets,O as readFunctionMetricIndexHits,H as readFunctionMetricScans,y as readFunctionMetrics,b as readFunctionMetricsTotals,W as readMetricHistory,$ as readQueryInsights,ee as readQueryMetrics,Se as readRequestLog,_ as recordAuthEvent,D as recordFunctionMetric,Y as recordMetricHistory,re as recordQueryMetric,Ie as redactArgs,de as resolveTraceAnchor,k as upsertIssueState};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import{s as n}from"./prune-marker-B4An9Nuj.mjs";import{r as e}from"./run-sql-0aPgJkIw.mjs";const u="__lunora_auth_metrics",r="__lunora_auth_metrics_buckets",_="app",c=6e4,N=1440,A=t=>Math.floor(t/c)*c,m=t=>{e(t,`CREATE TABLE IF NOT EXISTS "${u}" (
|
|
2
|
+
key TEXT PRIMARY KEY,
|
|
3
|
+
attempts INTEGER NOT NULL DEFAULT 0,
|
|
4
|
+
failures INTEGER NOT NULL DEFAULT 0,
|
|
5
|
+
since_ms INTEGER NOT NULL DEFAULT 0
|
|
6
|
+
)`),e(t,`CREATE TABLE IF NOT EXISTS "${r}" (
|
|
7
|
+
bucket_ms INTEGER PRIMARY KEY,
|
|
8
|
+
attempts INTEGER NOT NULL DEFAULT 0,
|
|
9
|
+
failures INTEGER NOT NULL DEFAULT 0
|
|
10
|
+
)`)},I=(t,s)=>{m(t);const E=s.outcome==="fail"?1:0;e(t,`INSERT INTO "${u}" (key, attempts, failures, since_ms)
|
|
11
|
+
VALUES (?, 1, ?, ?)
|
|
12
|
+
ON CONFLICT(key) DO UPDATE SET
|
|
13
|
+
attempts = attempts + 1,
|
|
14
|
+
failures = failures + excluded.failures,
|
|
15
|
+
since_ms = CASE WHEN since_ms = 0 THEN excluded.since_ms ELSE since_ms END`,_,E,s.ts);const T=A(s.ts);e(t,`INSERT INTO "${r}" (bucket_ms, attempts, failures)
|
|
16
|
+
VALUES (?, 1, ?)
|
|
17
|
+
ON CONFLICT(bucket_ms) DO UPDATE SET
|
|
18
|
+
attempts = attempts + 1,
|
|
19
|
+
failures = failures + excluded.failures`,T,E),n(t,T)&&e(t,`DELETE FROM "${r}"
|
|
20
|
+
WHERE bucket_ms <= (
|
|
21
|
+
SELECT MAX(bucket_ms) - ? FROM "${r}"
|
|
22
|
+
)`,N*c)},S=t=>{m(t);const s=e(t,`SELECT attempts, failures, since_ms FROM "${u}" WHERE key = ?`,_).toArray()[0],E=s?.attempts??0,T=s?.failures??0,o=s?.since_ms??0,i=e(t,`SELECT bucket_ms, attempts, failures FROM "${r}" ORDER BY bucket_ms ASC`).toArray().map(a=>({attempts:a.attempts,bucketMs:a.bucket_ms,failures:a.failures}));return{attempts:E,failureRate:E===0?0:T/E,failures:T,history:i,sinceMs:o}};export{r as AUTH_METRICS_BUCKETS_TABLE,c as AUTH_METRICS_BUCKET_MS,N as AUTH_METRICS_BUCKET_RETENTION,_ as AUTH_METRICS_ROW_KEY,u as AUTH_METRICS_TABLE,m as ensureAuthMetricsTables,S as readAuthMetrics,I as recordAuthEvent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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,
|
|
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
2
|
path TEXT PRIMARY KEY,
|
|
3
3
|
calls INTEGER NOT NULL DEFAULT 0,
|
|
4
4
|
errors INTEGER NOT NULL DEFAULT 0,
|
|
@@ -26,7 +26,7 @@ import{r}from"./run-sql-0aPgJkIw.mjs";const c="__lunora_metrics",T="__lunora_met
|
|
|
26
26
|
index_name TEXT NOT NULL,
|
|
27
27
|
reads INTEGER NOT NULL DEFAULT 0,
|
|
28
28
|
PRIMARY KEY (table_name, index_name)
|
|
29
|
-
)`),
|
|
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
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
31
|
VALUES (?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
32
32
|
ON CONFLICT(path) DO UPDATE SET
|
|
@@ -39,18 +39,18 @@ import{r}from"./run-sql-0aPgJkIw.mjs";const c="__lunora_metrics",T="__lunora_met
|
|
|
39
39
|
max_duration_ms = MAX(max_duration_ms, excluded.max_duration_ms),
|
|
40
40
|
last_called_at = excluded.last_called_at,
|
|
41
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,
|
|
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
43
|
VALUES (?, ?, 1, ?)
|
|
44
44
|
ON CONFLICT(path, bucket_ms) DO UPDATE SET
|
|
45
45
|
calls = calls + 1,
|
|
46
|
-
errors = errors + excluded.errors`,e.path,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
51
|
VALUES (?, ?, 1)
|
|
52
52
|
ON CONFLICT(path, table_name) DO UPDATE SET
|
|
53
53
|
scans = scans + 1`,e.path,l);for(const l of o)r(t,`INSERT INTO "${L}" (table_name, index_name, reads)
|
|
54
54
|
VALUES (?, ?, 1)
|
|
55
55
|
ON CONFLICT(table_name, index_name) DO UPDATE SET
|
|
56
|
-
reads = reads + 1`,l.table,l.index)},
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=new WeakMap,a=(t,n,r="")=>{let e=s.get(t);return e===void 0&&(e=new Map,s.set(t,e)),e.get(r)===n?!1:(e.set(r,n),!0)};export{a as s};
|
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.34",
|
|
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.22",
|
|
47
47
|
"@lunora/fingerprint": "1.0.0-alpha.7",
|
|
48
|
-
"@lunora/shard-engine": "1.0.0-alpha.
|
|
48
|
+
"@lunora/shard-engine": "1.0.0-alpha.34",
|
|
49
49
|
"@visulima/redact": "4.0.0"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./run-sql-0aPgJkIw.mjs";const u="__lunora_auth_metrics",T="__lunora_auth_metrics_buckets",_="app",c=6e4,n=1440,N=t=>Math.floor(t/c)*c,m=t=>{e(t,`CREATE TABLE IF NOT EXISTS "${u}" (
|
|
2
|
-
key TEXT PRIMARY KEY,
|
|
3
|
-
attempts INTEGER NOT NULL DEFAULT 0,
|
|
4
|
-
failures INTEGER NOT NULL DEFAULT 0,
|
|
5
|
-
since_ms INTEGER NOT NULL DEFAULT 0
|
|
6
|
-
)`),e(t,`CREATE TABLE IF NOT EXISTS "${T}" (
|
|
7
|
-
bucket_ms INTEGER PRIMARY KEY,
|
|
8
|
-
attempts INTEGER NOT NULL DEFAULT 0,
|
|
9
|
-
failures INTEGER NOT NULL DEFAULT 0
|
|
10
|
-
)`)},R=(t,s)=>{m(t);const E=s.outcome==="fail"?1:0;e(t,`INSERT INTO "${u}" (key, attempts, failures, since_ms)
|
|
11
|
-
VALUES (?, 1, ?, ?)
|
|
12
|
-
ON CONFLICT(key) DO UPDATE SET
|
|
13
|
-
attempts = attempts + 1,
|
|
14
|
-
failures = failures + excluded.failures,
|
|
15
|
-
since_ms = CASE WHEN since_ms = 0 THEN excluded.since_ms ELSE since_ms END`,_,E,s.ts);const a=N(s.ts);e(t,`INSERT INTO "${T}" (bucket_ms, attempts, failures)
|
|
16
|
-
VALUES (?, 1, ?)
|
|
17
|
-
ON CONFLICT(bucket_ms) DO UPDATE SET
|
|
18
|
-
attempts = attempts + 1,
|
|
19
|
-
failures = failures + excluded.failures`,a,E),e(t,`DELETE FROM "${T}"
|
|
20
|
-
WHERE bucket_ms <= (
|
|
21
|
-
SELECT MAX(bucket_ms) - ? FROM "${T}"
|
|
22
|
-
)`,n*c)},L=t=>{m(t);const s=e(t,`SELECT attempts, failures, since_ms FROM "${u}" WHERE key = ?`,_).toArray()[0],E=s?.attempts??0,a=s?.failures??0,o=s?.since_ms??0,i=e(t,`SELECT bucket_ms, attempts, failures FROM "${T}" ORDER BY bucket_ms ASC`).toArray().map(r=>({attempts:r.attempts,bucketMs:r.bucket_ms,failures:r.failures}));return{attempts:E,failureRate:E===0?0:a/E,failures:a,history:i,sinceMs:o}};export{T as AUTH_METRICS_BUCKETS_TABLE,c as AUTH_METRICS_BUCKET_MS,n as AUTH_METRICS_BUCKET_RETENTION,_ as AUTH_METRICS_ROW_KEY,u as AUTH_METRICS_TABLE,m as ensureAuthMetricsTables,L as readAuthMetrics,R as recordAuthEvent};
|