@runtimescope/collector 0.7.1 → 0.7.2
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/{chunk-VZSMLTUQ.js → chunk-TUFSIGGJ.js} +145 -39
- package/dist/chunk-TUFSIGGJ.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/standalone.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-VZSMLTUQ.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -863,16 +863,22 @@ declare class SqliteStore {
|
|
|
863
863
|
private writeBuffer;
|
|
864
864
|
private flushTimer;
|
|
865
865
|
private readonly batchSize;
|
|
866
|
+
private readonly dbPath;
|
|
867
|
+
private static readonly MAX_SNAPSHOTS_PER_SESSION;
|
|
866
868
|
private insertEventStmt;
|
|
867
869
|
private insertSessionStmt;
|
|
868
870
|
private updateSessionDisconnectedStmt;
|
|
869
871
|
constructor(options: SqliteStoreOptions);
|
|
872
|
+
private openDatabase;
|
|
873
|
+
private prepareStatements;
|
|
870
874
|
private createSchema;
|
|
871
875
|
addEvent(event: RuntimeEvent, project: string): void;
|
|
872
876
|
flush(): void;
|
|
873
877
|
saveSession(info: SessionInfoExtended): void;
|
|
874
878
|
updateSessionDisconnected(sessionId: string, disconnectedAt: number): void;
|
|
875
879
|
saveSessionMetrics(sessionId: string, project: string, metrics: unknown, label?: string): void;
|
|
880
|
+
/** Remove oldest snapshots for a session beyond the retention limit */
|
|
881
|
+
private pruneSnapshots;
|
|
876
882
|
getEvents(filter: HistoricalFilter): RuntimeEvent[];
|
|
877
883
|
getEventCount(filter: HistoricalFilter): number;
|
|
878
884
|
getSessions(project: string, limit?: number): SessionInfoExtended[];
|
|
@@ -1133,6 +1139,7 @@ declare class CollectorServer {
|
|
|
1133
1139
|
private connectCallbacks;
|
|
1134
1140
|
private disconnectCallbacks;
|
|
1135
1141
|
private pruneTimer;
|
|
1142
|
+
private heartbeatTimer;
|
|
1136
1143
|
private tlsConfig;
|
|
1137
1144
|
constructor(options?: CollectorServerOptions);
|
|
1138
1145
|
getStore(): EventStore;
|
|
@@ -1148,6 +1155,10 @@ declare class CollectorServer {
|
|
|
1148
1155
|
private tryStart;
|
|
1149
1156
|
private handleStartError;
|
|
1150
1157
|
private ensureSqliteStore;
|
|
1158
|
+
/** Catch runtime errors on the WSS so an unhandled error doesn't crash the process */
|
|
1159
|
+
private setupPersistentErrorHandler;
|
|
1160
|
+
/** Ping all connected clients every 15s — terminate those that don't respond */
|
|
1161
|
+
private startHeartbeat;
|
|
1151
1162
|
private setupConnectionHandler;
|
|
1152
1163
|
private handleMessage;
|
|
1153
1164
|
/** Find the WebSocket for a given sessionId */
|
|
@@ -1200,7 +1211,11 @@ declare function isSqliteAvailable(): boolean;
|
|
|
1200
1211
|
declare class ApiDiscoveryEngine {
|
|
1201
1212
|
private endpoints;
|
|
1202
1213
|
private store;
|
|
1214
|
+
private lastRebuildEventCount;
|
|
1215
|
+
private isDirty;
|
|
1203
1216
|
constructor(store: EventStore);
|
|
1217
|
+
/** Mark the cache dirty so the next read triggers a rebuild */
|
|
1218
|
+
markDirty(): void;
|
|
1204
1219
|
rebuild(): void;
|
|
1205
1220
|
private ingestEvent;
|
|
1206
1221
|
private refineEndpoints;
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
loadTlsOptions,
|
|
21
21
|
parseSessionJsonl,
|
|
22
22
|
resolveTlsConfig
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-TUFSIGGJ.js";
|
|
24
24
|
|
|
25
25
|
// src/issue-detector.ts
|
|
26
26
|
function detectIssues(events) {
|
|
@@ -477,15 +477,26 @@ function endpointKey(method, normalizedPath, baseUrl) {
|
|
|
477
477
|
var ApiDiscoveryEngine = class {
|
|
478
478
|
endpoints = /* @__PURE__ */ new Map();
|
|
479
479
|
store;
|
|
480
|
+
lastRebuildEventCount = 0;
|
|
481
|
+
isDirty = true;
|
|
480
482
|
constructor(store) {
|
|
481
483
|
this.store = store;
|
|
482
484
|
}
|
|
485
|
+
/** Mark the cache dirty so the next read triggers a rebuild */
|
|
486
|
+
markDirty() {
|
|
487
|
+
this.isDirty = true;
|
|
488
|
+
}
|
|
483
489
|
rebuild() {
|
|
484
|
-
this.endpoints.clear();
|
|
485
490
|
const events = this.store.getNetworkRequests();
|
|
491
|
+
if (!this.isDirty && events.length === this.lastRebuildEventCount) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
this.endpoints.clear();
|
|
486
495
|
for (const event of events) {
|
|
487
496
|
this.ingestEvent(event);
|
|
488
497
|
}
|
|
498
|
+
this.lastRebuildEventCount = events.length;
|
|
499
|
+
this.isDirty = false;
|
|
489
500
|
}
|
|
490
501
|
ingestEvent(event) {
|
|
491
502
|
const { baseUrl, normalizedPath } = normalizeUrl(event.url);
|