MCPcopy Create free account
hub / github.com/Kong/insomnia / recordInvocation

Function recordInvocation

packages/insomnia/src/main/plugin-window.ts:38–51  ·  view source on GitHub ↗
(method: string, outcome: 'ok' | 'error' | 'timeout', durationMs: number)

Source from the content-addressed store, hash-verified

36};
37
38function recordInvocation(method: string, outcome: 'ok' | 'error' | 'timeout', durationMs: number) {
39 let stats = bridgeMetrics.perMethod.get(method);
40 if (!stats) {
41 stats = { ok: 0, error: 0, timeout: 0, totalDurationMs: 0, maxDurationMs: 0 };
42 bridgeMetrics.perMethod.set(method, stats);
43 }
44 stats[outcome] += 1;
45 stats.totalDurationMs += durationMs;
46 if (durationMs > stats.maxDurationMs) {
47 stats.maxDurationMs = durationMs;
48 }
49 // Single structured log line per invocation; cheap to grep, easy to ship to analytics later.
50 console.log(`[plugin-bridge] invoke method=${method} outcome=${outcome} duration_ms=${durationMs}`);
51}
52
53export function getBridgeMetricsSnapshot() {
54 const perMethod: Record<string, BridgeMethodStats & { avgDurationMs: number }> = {};

Callers 2

ensureIpcListenersFunction · 0.85
invokeInPluginWindowFunction · 0.85

Calls 3

getMethod · 0.45
setMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected