@lunora/observability 1.0.0-alpha.187 → 1.0.0-alpha.188
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,12 +2290,6 @@ 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
2293
|
/**
|
|
2300
2294
|
* Buffered span count per trace, so {@link SpanBuffer.hasTrace} — run on
|
|
2301
2295
|
* every dispatch, usually a miss against a full ring — is a lookup, not a scan.
|
|
@@ -2319,7 +2313,11 @@ declare class SpanBuffer {
|
|
|
2319
2313
|
entries(): SpanEvent[];
|
|
2320
2314
|
/** Whether any buffered span belongs to `traceId`, as it was when pushed. */
|
|
2321
2315
|
hasTrace(traceId: string): boolean;
|
|
2322
|
-
/**
|
|
2316
|
+
/**
|
|
2317
|
+
* Append a span, evicting the oldest when at capacity. A frozen shallow copy
|
|
2318
|
+
* is stored, never the caller's object (which is shared with the sink and
|
|
2319
|
+
* stays writable), so the span and its `traceCounts` entry cannot diverge.
|
|
2320
|
+
*/
|
|
2323
2321
|
push(span: SpanEvent): void;
|
|
2324
2322
|
}
|
|
2325
2323
|
/** {@link foldTraces} result: the folded waterfalls plus the total distinct traces available before the `limit`. */
|
package/dist/index.d.ts
CHANGED
|
@@ -2290,12 +2290,6 @@ 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
2293
|
/**
|
|
2300
2294
|
* Buffered span count per trace, so {@link SpanBuffer.hasTrace} — run on
|
|
2301
2295
|
* every dispatch, usually a miss against a full ring — is a lookup, not a scan.
|
|
@@ -2319,7 +2313,11 @@ declare class SpanBuffer {
|
|
|
2319
2313
|
entries(): SpanEvent[];
|
|
2320
2314
|
/** Whether any buffered span belongs to `traceId`, as it was when pushed. */
|
|
2321
2315
|
hasTrace(traceId: string): boolean;
|
|
2322
|
-
/**
|
|
2316
|
+
/**
|
|
2317
|
+
* Append a span, evicting the oldest when at capacity. A frozen shallow copy
|
|
2318
|
+
* is stored, never the caller's object (which is shared with the sink and
|
|
2319
|
+
* stays writable), so the span and its `traceCounts` entry cannot diverge.
|
|
2320
|
+
*/
|
|
2323
2321
|
push(span: SpanEvent): void;
|
|
2324
2322
|
}
|
|
2325
2323
|
/** {@link foldTraces} result: the folded waterfalls plus the total distinct traces available before the `limit`. */
|
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-C8-8zvYg.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;traceCounts=new Map;droppedCount=0;constructor(c=I){this.capacity=l(c)}get dropped(){return this.droppedCount}get size(){return this.buffer.length}clear(){this.buffer.length=0,this.traceCounts.clear(),this.droppedCount=0}entries(){return[...this.buffer]}hasTrace(c){return this.traceCounts.has(c)}push(c){const r=Object.freeze({...c});if(this.buffer.push(r),this.traceCounts.set(r.traceId,(this.traceCounts.get(r.traceId)??0)+1),this.buffer.length>this.capacity){const o=this.buffer.shift(),n=(this.traceCounts.get(o.traceId)??1)-1;n===0?this.traceCounts.delete(o.traceId):this.traceCounts.set(o.traceId,n),this.droppedCount+=1}}}const b=50,v=d=>{const c=new Map;for(const r of d){const o=c.get(r.traceId);o===void 0?c.set(r.traceId,[r]):o.push(r)}return c},T=(d,c)=>{const r=d.find(n=>n.dispatch===!0);if(r!==void 0)return r;const o=d.toSorted((n,t)=>n.startTs-t.startTs);return o.find(n=>!c.has(n.parentSpanId))??o[0]},g=(d,c)=>{const r=new Map([[d.spanId,0]]);return o=>{const n=[],t=new Set;let e=o,a=0;for(;;){const i=r.get(e.spanId);if(i!==void 0){a=i;break}if(t.has(e.spanId))break;t.add(e.spanId),n.push(e);const h=c.get(e.parentSpanId);if(h===void 0)break;e=h}for(const[i,h]of n.toReversed().entries())r.set(h.spanId,a+i+1);return r.get(o.spanId)??a}},m=(d,c)=>{const r=new Map(d.map(t=>[t.spanId,t.depth])),o=new Map,n=[];for(const t of d){if(t.spanId===c){n.push(t);continue}const e=r.get(t.parentSpanId)===t.depth-1?t.parentSpanId:c,a=o.get(e);a===void 0?o.set(e,[t]):a.push(t)}for(const t of o.values())t.sort((e,a)=>e.offsetMs-a.offsetMs);return{childrenOf:o,roots:n}},M=(d,c)=>{const{childrenOf:r,roots:o}=m(d,c),n=[],t=new Set,e=o.toReversed();for(;e.length>0;){const a=e.pop();if(t.has(a))continue;t.add(a),n.push(a);const i=r.get(a.spanId);if(i!==void 0)for(const h of i.toReversed())e.push(h)}if(n.length!==d.length)for(const a of d)t.has(a)||n.push(a);return n},k=(d,c=b)=>{const r=v(d),o=[...r.entries()].map(([t,e])=>({group:e,startTs:Math.min(...e.map(a=>a.startTs)),traceId:t})).toSorted((t,e)=>e.startTs-t.startTs).slice(0,c),n=[];for(const{group:t,traceId:e}of o){const a=new Map(t.map(s=>[s.spanId,s])),i=T(t,a);if(i===void 0)continue;const h=g(i,a),{startTs:u}=i,f=Math.max(...t.map(s=>s.startTs+s.durationMs)),p=t.map(s=>({...s.attributes===void 0?{}:{attributes:s.attributes},depth:h(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-u),ok:s.ok,parentSpanId:s.parentSpanId,spanId:s.spanId}));n.push({durationMs:f-u,functionPath:i.functionPath,ok:t.every(s=>s.ok),rootName:i.name,...i.shardKey===void 0?{}:{shardKey:i.shardKey},spans:M(p,i.spanId),startTs:u,traceId:e})}return{total:r.size,traces:n.toSorted((t,e)=>e.startTs-t.startTs)}};export{b as DEFAULT_TRACE_LIMIT,C as SpanBuffer,k as foldTraces};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
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};
|