@lunora/observability 1.0.0-alpha.183 → 1.0.0-alpha.185
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
CHANGED
|
@@ -2290,6 +2290,17 @@ interface TraceSummary {
|
|
|
2290
2290
|
declare class SpanBuffer {
|
|
2291
2291
|
private readonly buffer;
|
|
2292
2292
|
private readonly capacity;
|
|
2293
|
+
/**
|
|
2294
|
+
* The trace id each buffered span was counted under, parallel to `buffer`.
|
|
2295
|
+
* Eviction decrements this, not `span.traceId`, so a caller that edits a
|
|
2296
|
+
* retained span cannot strand a count for an id that no longer matches.
|
|
2297
|
+
*/
|
|
2298
|
+
private readonly countedIds;
|
|
2299
|
+
/**
|
|
2300
|
+
* Buffered span count per trace, so {@link SpanBuffer.hasTrace} — run on
|
|
2301
|
+
* every dispatch, usually a miss against a full ring — is a lookup, not a scan.
|
|
2302
|
+
*/
|
|
2303
|
+
private readonly traceCounts;
|
|
2293
2304
|
/** How many spans the ring has evicted since it was last cleared. */
|
|
2294
2305
|
private droppedCount;
|
|
2295
2306
|
constructor(capacity?: number);
|
|
@@ -2306,11 +2317,7 @@ declare class SpanBuffer {
|
|
|
2306
2317
|
clear(): void;
|
|
2307
2318
|
/** Snapshot of the buffered spans in insertion order. Fresh array per call. */
|
|
2308
2319
|
entries(): SpanEvent[];
|
|
2309
|
-
/**
|
|
2310
|
-
* Whether any buffered span belongs to `traceId`. A membership test rather
|
|
2311
|
-
* than `entries().some(...)` so the per-dispatch check that decides whether
|
|
2312
|
-
* to record a root span doesn't copy the whole ring on every request.
|
|
2313
|
-
*/
|
|
2320
|
+
/** Whether any buffered span belongs to `traceId`, as it was when pushed. */
|
|
2314
2321
|
hasTrace(traceId: string): boolean;
|
|
2315
2322
|
/** Append a span, evicting the oldest when at capacity. */
|
|
2316
2323
|
push(span: SpanEvent): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -2290,6 +2290,17 @@ interface TraceSummary {
|
|
|
2290
2290
|
declare class SpanBuffer {
|
|
2291
2291
|
private readonly buffer;
|
|
2292
2292
|
private readonly capacity;
|
|
2293
|
+
/**
|
|
2294
|
+
* The trace id each buffered span was counted under, parallel to `buffer`.
|
|
2295
|
+
* Eviction decrements this, not `span.traceId`, so a caller that edits a
|
|
2296
|
+
* retained span cannot strand a count for an id that no longer matches.
|
|
2297
|
+
*/
|
|
2298
|
+
private readonly countedIds;
|
|
2299
|
+
/**
|
|
2300
|
+
* Buffered span count per trace, so {@link SpanBuffer.hasTrace} — run on
|
|
2301
|
+
* every dispatch, usually a miss against a full ring — is a lookup, not a scan.
|
|
2302
|
+
*/
|
|
2303
|
+
private readonly traceCounts;
|
|
2293
2304
|
/** How many spans the ring has evicted since it was last cleared. */
|
|
2294
2305
|
private droppedCount;
|
|
2295
2306
|
constructor(capacity?: number);
|
|
@@ -2306,11 +2317,7 @@ declare class SpanBuffer {
|
|
|
2306
2317
|
clear(): void;
|
|
2307
2318
|
/** Snapshot of the buffered spans in insertion order. Fresh array per call. */
|
|
2308
2319
|
entries(): SpanEvent[];
|
|
2309
|
-
/**
|
|
2310
|
-
* Whether any buffered span belongs to `traceId`. A membership test rather
|
|
2311
|
-
* than `entries().some(...)` so the per-dispatch check that decides whether
|
|
2312
|
-
* to record a root span doesn't copy the whole ring on every request.
|
|
2313
|
-
*/
|
|
2320
|
+
/** Whether any buffered span belongs to `traceId`, as it was when pushed. */
|
|
2314
2321
|
hasTrace(traceId: string): boolean;
|
|
2315
2322
|
/** Append a span, evicting the oldest when at capacity. */
|
|
2316
2323
|
push(span: SpanEvent): void;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AUTH_METRICS_BUCKETS_TABLE as t,AUTH_METRICS_BUCKET_MS as s,AUTH_METRICS_BUCKET_RETENTION as a,AUTH_METRICS_TABLE as o,ensureAuthMetricsTables as T,readAuthMetrics as E,recordAuthEvent as S}from"./packem_shared/AUTH_METRICS_BUCKETS_TABLE-BpH1ZAgX.mjs";import{createMetrics as i,createSpanCollector as c,createTracedFetch as n,createTracer as I,dispatchRootSpan as u}from"./packem_shared/createMetrics-C6AXtDTF.mjs";import{createDatabaseTally as A,formatTally as N,instrumentDatabase as p,instrumentSqlClient as C}from"./packem_shared/createDatabaseTally-BNj6kmo2.mjs";import{FUNCTION_METRICS_BUCKETS_TABLE as f,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 O,readFunctionMetricIndexHits as H,readFunctionMetricScans as y,readFunctionMetrics as b,readFunctionMetricsTotals as h,recordFunctionMetric as v}from"./packem_shared/FUNCTION_METRICS_BUCKETS_TABLE-Dha-40Hv.mjs";import{applyHostRootSpan as K,setHostSpanAttributes as q}from"./packem_shared/applyHostRootSpan-DToRfMn8.mjs";import{DEFAULT_EXPLAIN_ISSUE_MODEL as Q,explainIssue as V,parseExplainIssueArgs as k}from"./packem_shared/DEFAULT_EXPLAIN_ISSUE_MODEL-BkFTgdkd.mjs";import{ISSUE_SEVERITIES as X,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{MetricBuffer as Z}from"./packem_shared/MetricBuffer-BUw1hK3f.mjs";import{readMetricHistory as ee,recordMetricHistory as re}from"./packem_shared/readMetricHistory-BjPDSBkS.mjs";import{latencyBucketIndex as se,readQueryInsights as ae,readQueryMetrics as oe,recordQueryMetric as Te}from"./packem_shared/latencyBucketIndex--kZoW0vc.mjs";import{N as Se,R as _e,S as ie,a as ce,c as ne,e as Ie,b as ue,d as Me,m as Ae,p as Ne,r as pe,f as Ce,g as de,h as fe,s as Re,i as Ue}from"./packem_shared/request-log-B7gOe-_k.mjs";import{MIN_ADMIN_TOKEN_LENGTH as le,MIN_AUTH_SECRET_LENGTH as Le,buildSecurityAudit as xe}from"./packem_shared/MIN_ADMIN_TOKEN_LENGTH-DSOQ6rno.mjs";import{SpanBuffer as Fe,foldTraces as ge}from"./packem_shared/SpanBuffer-
|
|
1
|
+
import{AUTH_METRICS_BUCKETS_TABLE as t,AUTH_METRICS_BUCKET_MS as s,AUTH_METRICS_BUCKET_RETENTION as a,AUTH_METRICS_TABLE as o,ensureAuthMetricsTables as T,readAuthMetrics as E,recordAuthEvent as S}from"./packem_shared/AUTH_METRICS_BUCKETS_TABLE-BpH1ZAgX.mjs";import{createMetrics as i,createSpanCollector as c,createTracedFetch as n,createTracer as I,dispatchRootSpan as u}from"./packem_shared/createMetrics-C6AXtDTF.mjs";import{createDatabaseTally as A,formatTally as N,instrumentDatabase as p,instrumentSqlClient as C}from"./packem_shared/createDatabaseTally-BNj6kmo2.mjs";import{FUNCTION_METRICS_BUCKETS_TABLE as f,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 O,readFunctionMetricIndexHits as H,readFunctionMetricScans as y,readFunctionMetrics as b,readFunctionMetricsTotals as h,recordFunctionMetric as v}from"./packem_shared/FUNCTION_METRICS_BUCKETS_TABLE-Dha-40Hv.mjs";import{applyHostRootSpan as K,setHostSpanAttributes as q}from"./packem_shared/applyHostRootSpan-DToRfMn8.mjs";import{DEFAULT_EXPLAIN_ISSUE_MODEL as Q,explainIssue as V,parseExplainIssueArgs as k}from"./packem_shared/DEFAULT_EXPLAIN_ISSUE_MODEL-BkFTgdkd.mjs";import{ISSUE_SEVERITIES as X,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{MetricBuffer as Z}from"./packem_shared/MetricBuffer-BUw1hK3f.mjs";import{readMetricHistory as ee,recordMetricHistory as re}from"./packem_shared/readMetricHistory-BjPDSBkS.mjs";import{latencyBucketIndex as se,readQueryInsights as ae,readQueryMetrics as oe,recordQueryMetric as Te}from"./packem_shared/latencyBucketIndex--kZoW0vc.mjs";import{N as Se,R as _e,S as ie,a as ce,c as ne,e as Ie,b as ue,d as Me,m as Ae,p as Ne,r as pe,f as Ce,g as de,h as fe,s as Re,i as Ue}from"./packem_shared/request-log-B7gOe-_k.mjs";import{MIN_ADMIN_TOKEN_LENGTH as le,MIN_AUTH_SECRET_LENGTH as Le,buildSecurityAudit as xe}from"./packem_shared/MIN_ADMIN_TOKEN_LENGTH-DSOQ6rno.mjs";import{SpanBuffer as Fe,foldTraces as ge}from"./packem_shared/SpanBuffer-1aPmlIHd.mjs";import{findDanglingReferences as He}from"./packem_shared/findDanglingReferences-BaOyIdxz.mjs";import{resolveTraceAnchor as be}from"./packem_shared/resolveTraceAnchor-DDAPZRBB.mjs";export{t as AUTH_METRICS_BUCKETS_TABLE,s as AUTH_METRICS_BUCKET_MS,a as AUTH_METRICS_BUCKET_RETENTION,o as AUTH_METRICS_TABLE,Q as DEFAULT_EXPLAIN_ISSUE_MODEL,f 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,X as ISSUE_SEVERITIES,j as ISSUE_STATE_TABLE,w as ISSUE_STATUSES,W as LogBuffer,le as MIN_ADMIN_TOKEN_LENGTH,Le as MIN_AUTH_SECRET_LENGTH,Z as MetricBuffer,Se as NO_SENSITIVE_SCOPE,_e as REQUEST_LOG_TABLE,ie as SENSITIVE_ARG_MASK,Fe as SpanBuffer,ce as appendRequestLogEntry,K as applyHostRootSpan,xe as buildSecurityAudit,A as createDatabaseTally,i as createMetrics,ne as createSensitiveScope,c as createSpanCollector,n as createTracedFetch,I as createTracer,u as dispatchRootSpan,Ie as emitLogEvent,ue as emitRequestLogEvent,T as ensureAuthMetricsTables,F as ensureFunctionMetricsTables,Me as ensureRequestLogTable,V as explainIssue,He as findDanglingReferences,ge as foldTraces,N as formatTally,p as instrumentDatabase,C as instrumentSqlClient,se as latencyBucketIndex,Ae as maskSensitiveArgs,g as mergeScanAttribution,k as parseExplainIssueArgs,Ne as parseLogArgs,E as readAuthMetrics,pe as readErrorIssues,O as readFunctionMetricBuckets,H as readFunctionMetricIndexHits,y as readFunctionMetricScans,b as readFunctionMetrics,h as readFunctionMetricsTotals,ee as readMetricHistory,ae as readQueryInsights,oe as readQueryMetrics,Ce as readRequestLog,S as recordAuthEvent,v as recordFunctionMetric,re as recordMetricHistory,Te as recordQueryMetric,de as redactArgs,fe as redactCredentials,be as resolveTraceAnchor,Re as sensitiveNames,Ue as sensitiveValues,q as setHostSpanAttributes,z as upsertIssueState};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DEFAULT_CAPACITY as I,normalizeCapacity as l}from"./LogBuffer-BmD4CfV0.mjs";class C{buffer=[];capacity;countedIds=[];traceCounts=new Map;droppedCount=0;constructor(s=I){this.capacity=l(s)}get dropped(){return this.droppedCount}get size(){return this.buffer.length}clear(){this.buffer.length=0,this.countedIds.length=0,this.traceCounts.clear(),this.droppedCount=0}entries(){return[...this.buffer]}hasTrace(s){return this.traceCounts.has(s)}push(s){if(this.buffer.push(s),this.countedIds.push(s.traceId),this.traceCounts.set(s.traceId,(this.traceCounts.get(s.traceId)??0)+1),this.buffer.length>this.capacity){this.buffer.shift();const n=this.countedIds.shift(),a=(this.traceCounts.get(n)??1)-1;a===0?this.traceCounts.delete(n):this.traceCounts.set(n,a),this.droppedCount+=1}}}const g=50,v=d=>{const s=new Map;for(const n of d){const a=s.get(n.traceId);a===void 0?s.set(n.traceId,[n]):a.push(n)}return s},T=(d,s)=>{const n=d.find(c=>c.dispatch===!0);if(n!==void 0)return n;const a=d.toSorted((c,t)=>c.startTs-t.startTs);return a.find(c=>!s.has(c.parentSpanId))??a[0]},b=(d,s)=>{const n=new Map([[d.spanId,0]]);return a=>{const c=[],t=new Set;let e=a,o=0;for(;;){const i=n.get(e.spanId);if(i!==void 0){o=i;break}if(t.has(e.spanId))break;t.add(e.spanId),c.push(e);const h=s.get(e.parentSpanId);if(h===void 0)break;e=h}for(const[i,h]of c.toReversed().entries())n.set(h.spanId,o+i+1);return n.get(a.spanId)??o}},m=(d,s)=>{const n=new Map(d.map(t=>[t.spanId,t.depth])),a=new Map,c=[];for(const t of d){if(t.spanId===s){c.push(t);continue}const e=n.get(t.parentSpanId)===t.depth-1?t.parentSpanId:s,o=a.get(e);o===void 0?a.set(e,[t]):o.push(t)}for(const t of a.values())t.sort((e,o)=>e.offsetMs-o.offsetMs);return{childrenOf:a,roots:c}},M=(d,s)=>{const{childrenOf:n,roots:a}=m(d,s),c=[],t=new Set,e=a.toReversed();for(;e.length>0;){const o=e.pop();if(t.has(o))continue;t.add(o),c.push(o);const i=n.get(o.spanId);if(i!==void 0)for(const h of i.toReversed())e.push(h)}if(c.length!==d.length)for(const o of d)t.has(o)||c.push(o);return c},k=(d,s=g)=>{const n=v(d),a=[...n.entries()].map(([t,e])=>({group:e,startTs:Math.min(...e.map(o=>o.startTs)),traceId:t})).toSorted((t,e)=>e.startTs-t.startTs).slice(0,s),c=[];for(const{group:t,traceId:e}of a){const o=new Map(t.map(r=>[r.spanId,r])),i=T(t,o);if(i===void 0)continue;const h=b(i,o),{startTs:u}=i,f=Math.max(...t.map(r=>r.startTs+r.durationMs)),p=t.map(r=>({...r.attributes===void 0?{}:{attributes:r.attributes},depth:h(r),durationMs:r.durationMs,...r.error===void 0?{}:{error:r.error},...r.events===void 0?{}:{events:r.events},...r.kind===void 0?{}:{kind:r.kind},name:r.name,offsetMs:Math.max(0,r.startTs-u),ok:r.ok,parentSpanId:r.parentSpanId,spanId:r.spanId}));c.push({durationMs:f-u,functionPath:i.functionPath,ok:t.every(r=>r.ok),rootName:i.name,...i.shardKey===void 0?{}:{shardKey:i.shardKey},spans:M(p,i.spanId),startTs:u,traceId:e})}return{total:n.size,traces:c.toSorted((t,e)=>e.startTs-t.startTs)}};export{g as DEFAULT_TRACE_LIMIT,C as SpanBuffer,k as foldTraces};
|
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.185",
|
|
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,8 +45,8 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
47
47
|
"@lunora/fingerprint": "1.0.0-alpha.10",
|
|
48
|
-
"@lunora/shard-engine": "1.0.0-alpha.
|
|
49
|
-
"@lunora/wire": "1.0.0-alpha.
|
|
48
|
+
"@lunora/shard-engine": "1.0.0-alpha.172",
|
|
49
|
+
"@lunora/wire": "1.0.0-alpha.4",
|
|
50
50
|
"@visulima/redact": "5.0.0"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{DEFAULT_CAPACITY as l,normalizeCapacity as I}from"./LogBuffer-BmD4CfV0.mjs";class k{buffer=[];capacity;droppedCount=0;constructor(n=l){this.capacity=I(n)}get dropped(){return this.droppedCount}get size(){return this.buffer.length}clear(){this.buffer.length=0,this.droppedCount=0}entries(){return[...this.buffer]}hasTrace(n){return this.buffer.some(o=>o.traceId===n)}push(n){this.buffer.push(n),this.buffer.length>this.capacity&&(this.buffer.shift(),this.droppedCount+=1)}}const b=50,T=c=>{const n=new Map;for(const o of c){const d=n.get(o.traceId);d===void 0?n.set(o.traceId,[o]):d.push(o)}return n},v=(c,n)=>{const o=c.find(a=>a.dispatch===!0);if(o!==void 0)return o;const d=c.toSorted((a,t)=>a.startTs-t.startTs);return d.find(a=>!n.has(a.parentSpanId))??d[0]},m=(c,n)=>{const o=new Map([[c.spanId,0]]);return d=>{const a=[],t=new Set;let e=d,r=0;for(;;){const i=o.get(e.spanId);if(i!==void 0){r=i;break}if(t.has(e.spanId))break;t.add(e.spanId),a.push(e);const f=n.get(e.parentSpanId);if(f===void 0)break;e=f}for(const[i,f]of a.toReversed().entries())o.set(f.spanId,r+i+1);return o.get(d.spanId)??r}},g=(c,n)=>{const o=new Map(c.map(t=>[t.spanId,t.depth])),d=new Map,a=[];for(const t of c){if(t.spanId===n){a.push(t);continue}const e=o.get(t.parentSpanId)===t.depth-1?t.parentSpanId:n,r=d.get(e);r===void 0?d.set(e,[t]):r.push(t)}for(const t of d.values())t.sort((e,r)=>e.offsetMs-r.offsetMs);return{childrenOf:d,roots:a}},y=(c,n)=>{const{childrenOf:o,roots:d}=g(c,n),a=[],t=new Set,e=d.toReversed();for(;e.length>0;){const r=e.pop();if(t.has(r))continue;t.add(r),a.push(r);const i=o.get(r.spanId);if(i!==void 0)for(const f of i.toReversed())e.push(f)}if(a.length!==c.length)for(const r of c)t.has(r)||a.push(r);return a},S=(c,n=b)=>{const o=T(c),d=[...o.entries()].map(([t,e])=>({group:e,startTs:Math.min(...e.map(r=>r.startTs)),traceId:t})).toSorted((t,e)=>e.startTs-t.startTs).slice(0,n),a=[];for(const{group:t,traceId:e}of d){const r=new Map(t.map(s=>[s.spanId,s])),i=v(t,r);if(i===void 0)continue;const f=m(i,r),{startTs:p}=i,h=Math.max(...t.map(s=>s.startTs+s.durationMs)),u=t.map(s=>({...s.attributes===void 0?{}:{attributes:s.attributes},depth:f(s),durationMs:s.durationMs,...s.error===void 0?{}:{error:s.error},...s.events===void 0?{}:{events:s.events},...s.kind===void 0?{}:{kind:s.kind},name:s.name,offsetMs:Math.max(0,s.startTs-p),ok:s.ok,parentSpanId:s.parentSpanId,spanId:s.spanId}));a.push({durationMs:h-p,functionPath:i.functionPath,ok:t.every(s=>s.ok),rootName:i.name,...i.shardKey===void 0?{}:{shardKey:i.shardKey},spans:y(u,i.spanId),startTs:p,traceId:e})}return{total:o.size,traces:a.toSorted((t,e)=>e.startTs-t.startTs)}};export{b as DEFAULT_TRACE_LIMIT,k as SpanBuffer,S as foldTraces};
|