@lunora/observability 1.0.0-alpha.133 → 1.0.0-alpha.135
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.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 S,createSpanCollector as n,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-
|
|
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 S,createSpanCollector as n,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 R,FUNCTION_METRICS_BUCKET_MS as U,FUNCTION_METRICS_BUCKET_RETENTION as d,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-ChlIe0vF.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 P}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{readQueryInsights as oe,readQueryMetrics as Te,recordQueryMetric as ae}from"./packem_shared/readQueryInsights-DkQfxGfP.mjs";import{R as Ee,a as _e,e as ce,b as Se,c as ne,p as ie,r as Ie,d as ue,f as Me}from"./packem_shared/request-log-YtJxmSWX.mjs";import{MIN_ADMIN_TOKEN_LENGTH as Ae,MIN_AUTH_SECRET_LENGTH as Ce,buildSecurityAudit as Ne}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 me}from"./packem_shared/findDanglingReferences-BaOyIdxz.mjs";import{resolveTraceAnchor as le}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,R as FUNCTION_METRICS_BUCKETS_TABLE,U as FUNCTION_METRICS_BUCKET_MS,d 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,Ae as MIN_ADMIN_TOKEN_LENGTH,Ce as MIN_AUTH_SECRET_LENGTH,Z as MetricBuffer,Ee as REQUEST_LOG_TABLE,Re as SpanBuffer,_e as appendRequestLogEntry,q as applyHostRootSpan,Ne as buildSecurityAudit,p as createDatabaseTally,S as createMetrics,n as createSpanCollector,i as createTracedFetch,I as createTracer,u as dispatchRootSpan,ce as emitLogEvent,Se as emitRequestLogEvent,s as ensureAuthMetricsTables,F as ensureFunctionMetricsTables,ne as ensureRequestLogTable,X as explainIssue,me as findDanglingReferences,Ue as foldTraces,A as formatTally,C as instrumentDatabase,N as instrumentSqlClient,g as mergeScanAttribution,P as parseExplainIssueArgs,ie as parseLogArgs,E as readAuthMetrics,Ie as readErrorIssues,H as readFunctionMetricBuckets,O as readFunctionMetricIndexHits,y as readFunctionMetricScans,b as readFunctionMetrics,D as readFunctionMetricsTotals,ee as readMetricHistory,oe as readQueryInsights,Te as readQueryMetrics,ue as readRequestLog,_ as recordAuthEvent,h as recordFunctionMetric,re as recordMetricHistory,ae as recordQueryMetric,Me as redactArgs,le as resolveTraceAnchor,v as setHostSpanAttributes,z as upsertIssueState};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{o as g}from"./otlp-DR7601NL.mjs";import{f as p}from"./request-log-YtJxmSWX.mjs";import{toErrorType as E}from"./resolveTraceAnchor-DDAPZRBB.mjs";const h=new Set(["ALTER","ANALYZE","BEGIN","CALL","COMMIT","COPY","CREATE","DEALLOCATE","DELETE","DESCRIBE","DO","DROP","EXECUTE","EXPLAIN","GRANT","INSERT","LISTEN","LOCK","MERGE","NOTIFY","PREPARE","REFRESH","RELEASE","REPLACE","REVOKE","ROLLBACK","SAVEPOINT","SELECT","SET","SHOW","START","TABLE","TRUNCATE","UNLISTEN","UPDATE","VACUUM","VALUES","WITH"]),d="OTHER",R=/^[a-z]+/iu,O=t=>{if(typeof t!="string")return d;let e=0;for(;e<t.length;){const o=t.charAt(e);if(o==="("||o.trim()==="")e+=1;else if(t.startsWith("--",e)){const a=t.indexOf(`
|
|
2
|
+
`,e);if(a===-1)return d;e=a+1}else if(t.startsWith("/*",e)){const a=t.indexOf("*/",e+2);if(a===-1)return d;e=a+2}else break}const r=R.exec(t.slice(e,e+16))?.[0].toUpperCase();return r!==void 0&&h.has(r)?r:d},m=t=>t??"other_sql",S=100,A=new Set(["aggregate","count","delete","deleteMany","deleteWhere","explain","findFirst","findFirstOrThrow","findMany","get","groupBy","insert","insertMany","insertManyUnsafe","lookupById","patch","patchIf","patchMany","patchWhere","rank","rankBefore","rankPage","rankPageRows","related","replace","restore"]),I=new Set(["aggregate","count","deleteWhere","explain","findFirst","findFirstOrThrow","findMany","groupBy","insert","insertMany","insertManyUnsafe","patchIf","patchWhere","rank","rankBefore","rankPage","rankPageRows"]),P=(t,e)=>{if(!I.has(t))return;const r=e[0];return typeof r=="string"&&r.length>0?r:void 0},l=t=>t instanceof Error?t.message:typeof t=="string"?t:JSON.stringify(t)??String(t),L=(t,e,r)=>r==="redact"?p(l(t),e.captureRaw):e.captureRaw===!0?l(t):E(t),u=(t,e,r)=>{const{durationMs:o,failure:a,startTs:n}=e;return{durationMs:o,...a===void 0?{}:{error:{message:L(a,t,r),type:E(a)}},functionPath:t.functionPath,kind:"client",ok:a===void 0,parentSpanId:t.anchor.rootSpanId,...t.anchor.rayId===void 0?{}:{rayId:t.anchor.rayId},shardKey:t.shardKey,spanId:g(8),startTs:n,traceId:t.anchor.traceId,userId:t.userId()}},y=async(t,e,r,o)=>{const a=Date.now();let n,s;try{return s=await r(),s}catch(i){throw n=i,i}finally{const i=Date.now()-a,{tally:c}=t;c.calls+=1,c.durationMs+=i,c.perOperation[e]=(c.perOperation[e]??0)+1,n!==void 0&&(c.errors+=1);try{t.mode==="spans"&&(c.spansEmitted>=S?c.spansTruncated=!0:(c.spansEmitted+=1,t.record(o({durationMs:i,failure:n,result:s,startTs:a}))))}catch{}}},T=(t,e,r)=>{const o=new Map;return new Proxy({},{get(a,n){const s=Reflect.get(t,n,t);if(typeof n!="string"||typeof s!="function"||!e(n))return s;const i=s,c=o.get(n);if(c?.original===i)return c.instrumented;const f=r(n,i.bind(t));return o.set(n,{instrumented:f,original:i}),f},getOwnPropertyDescriptor(a,n){const s=Reflect.getOwnPropertyDescriptor(t,n);return s===void 0?void 0:{...s,configurable:!0}},defineProperty(a,n,s){return s.configurable===!1?!1:Reflect.defineProperty(t,n,s)},deleteProperty(a,n){return Reflect.deleteProperty(t,n)},getPrototypeOf(){return Reflect.getPrototypeOf(t)},has(a,n){return Reflect.has(t,n)},ownKeys(){return Reflect.ownKeys(t)},set(a,n,s){return Reflect.set(t,n,s,t)}})},_=(t,e)=>e.mode==="off"?t:T(t,r=>A.has(r),(r,o)=>async(...a)=>{const n=P(r,a);return y(e,r,()=>o(...a),s=>({...u(e,s,"redact"),attributes:{"db.operation.name":r,...n===void 0?{}:{"db.collection.name":n},"db.system.name":"sqlite"},name:n===void 0?`db.${r}`:`db.${r} ${n}`}))}),N=(t,e)=>{if(e.mode==="off")return t;const r=m(t.dbSystem);return T(t,o=>o==="query",(o,a)=>async(...n)=>{const s=O(n[0]);return y(e,s,()=>a(...n),i=>({...u(e,i,"type-only"),attributes:{"db.operation.name":s,...Array.isArray(i.result)?{"db.response.returned_rows":i.result.length}:{},"db.system.name":r},name:`sql.${s}`}))})},C=()=>({calls:0,durationMs:0,errors:0,perOperation:{},spansEmitted:0,spansTruncated:!1}),D=(t,e="db")=>{const r={[`${e}.calls`]:t.calls,[`${e}.duration_ms`]:t.durationMs};t.errors>0&&(r[`${e}.errors`]=t.errors),t.spansTruncated&&(r[`${e}.spans_truncated`]=!0);for(const[o,a]of Object.entries(t.perOperation))r[`${e}.op.${o}`]=a;return r};export{C as createDatabaseTally,D as formatTally,_ as instrumentDatabase,N as instrumentSqlClient};
|
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.135",
|
|
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.125",
|
|
49
49
|
"@visulima/redact": "5.0.0"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{o as y}from"./otlp-DR7601NL.mjs";import{f as h}from"./request-log-YtJxmSWX.mjs";import{toErrorType as E}from"./resolveTraceAnchor-DDAPZRBB.mjs";const p=new Set(["ALTER","ANALYZE","BEGIN","CALL","COMMIT","COPY","CREATE","DEALLOCATE","DELETE","DESCRIBE","DO","DROP","EXECUTE","EXPLAIN","GRANT","INSERT","LISTEN","LOCK","MERGE","NOTIFY","PREPARE","REFRESH","RELEASE","REPLACE","REVOKE","ROLLBACK","SAVEPOINT","SELECT","SET","SHOW","START","TABLE","TRUNCATE","UNLISTEN","UPDATE","VACUUM","VALUES","WITH"]),d="OTHER",O=/^[a-z]+/iu,g=t=>{if(typeof t!="string")return d;let e=0;for(;e<t.length;){const a=t.charAt(e);if(a==="("||a.trim()==="")e+=1;else if(t.startsWith("--",e)){const s=t.indexOf(`
|
|
2
|
-
`,e);if(s===-1)return d;e=s+1}else if(t.startsWith("/*",e)){const s=t.indexOf("*/",e+2);if(s===-1)return d;e=s+2}else break}const r=O.exec(t.slice(e,e+16))?.[0].toUpperCase();return r!==void 0&&p.has(r)?r:d},R=t=>t??"other_sql",S=100,m=new Set(["aggregate","count","delete","deleteMany","deleteWhere","explain","findFirst","findFirstOrThrow","findMany","get","groupBy","insert","insertMany","insertManyUnsafe","lookupById","patch","patchIf","patchMany","patchWhere","rank","rankBefore","rankPage","rankPageRows","related","replace","restore"]),A=new Set(["aggregate","count","deleteWhere","explain","findFirst","findFirstOrThrow","findMany","groupBy","insert","insertMany","insertManyUnsafe","patchIf","patchWhere","rank","rankBefore","rankPage","rankPageRows"]),I=(t,e)=>{if(!A.has(t))return;const r=e[0];return typeof r=="string"&&r.length>0?r:void 0},f=t=>t instanceof Error?t.message:typeof t=="string"?t:JSON.stringify(t)??String(t),L=(t,e,r)=>r==="redact"?h(f(t),e.captureRaw):e.captureRaw===!0?f(t):E(t),u=(t,e,r)=>{const{durationMs:a,failure:s,startTs:n}=e;return{durationMs:a,...s===void 0?{}:{error:{message:L(s,t,r),type:E(s)}},functionPath:t.functionPath,kind:"client",ok:s===void 0,parentSpanId:t.anchor.rootSpanId,...t.anchor.rayId===void 0?{}:{rayId:t.anchor.rayId},shardKey:t.shardKey,spanId:y(8),startTs:n,traceId:t.anchor.traceId,userId:t.userId()}},l=async(t,e,r,a)=>{const s=Date.now();let n,o;try{return o=await r(),o}catch(i){throw n=i,i}finally{const i=Date.now()-s,{tally:c}=t;c.calls+=1,c.durationMs+=i,c.perOperation[e]=(c.perOperation[e]??0)+1,n!==void 0&&(c.errors+=1);try{t.mode==="spans"&&(c.spansEmitted>=S?c.spansTruncated=!0:(c.spansEmitted+=1,t.record(a({durationMs:i,failure:n,result:o,startTs:s}))))}catch{}}},T=(t,e,r)=>{const a=new Map;return new Proxy({},{get(s,n){const o=Reflect.get(t,n,t);if(typeof n!="string"||typeof o!="function"||!e(n))return o;let i=a.get(n);return i===void 0&&(i=r(n,o.bind(t)),a.set(n,i)),i},getOwnPropertyDescriptor(s,n){const o=Reflect.getOwnPropertyDescriptor(t,n);return o===void 0?void 0:{...o,configurable:!0}},getPrototypeOf(){return Reflect.getPrototypeOf(t)},has(s,n){return Reflect.has(t,n)},ownKeys(){return Reflect.ownKeys(t)}})},b=(t,e)=>e.mode==="off"?t:T(t,r=>m.has(r),(r,a)=>async(...s)=>{const n=I(r,s);return l(e,r,()=>a(...s),o=>({...u(e,o,"redact"),attributes:{"db.operation.name":r,...n===void 0?{}:{"db.collection.name":n},"db.system.name":"sqlite"},name:n===void 0?`db.${r}`:`db.${r} ${n}`}))}),N=(t,e)=>{if(e.mode==="off")return t;const r=R(t.dbSystem);return T(t,a=>a==="query",(a,s)=>async(...n)=>{const o=g(n[0]);return l(e,o,()=>s(...n),i=>({...u(e,i,"type-only"),attributes:{"db.operation.name":o,...Array.isArray(i.result)?{"db.response.returned_rows":i.result.length}:{},"db.system.name":r},name:`sql.${o}`}))})},C=()=>({calls:0,durationMs:0,errors:0,perOperation:{},spansEmitted:0,spansTruncated:!1}),_=(t,e="db")=>{const r={[`${e}.calls`]:t.calls,[`${e}.duration_ms`]:t.durationMs};t.errors>0&&(r[`${e}.errors`]=t.errors),t.spansTruncated&&(r[`${e}.spans_truncated`]=!0);for(const[a,s]of Object.entries(t.perOperation))r[`${e}.op.${a}`]=s;return r};export{C as createDatabaseTally,_ as formatTally,b as instrumentDatabase,N as instrumentSqlClient};
|