Skip to content

Commit 6bb3eab

Browse files
authored
fix(metrics): remove browserless_socket_handles gauge (#113)
Per-remote-address label creates unbounded cardinality (~525 active series + massive churn). Also dropped at Alloy level. The browserless_active_handles_by_type gauge (by constructor type, not IP) remains for dashboard use.
1 parent 1cb9ace commit 6bb3eab

1 file changed

Lines changed: 2 additions & 18 deletions

File tree

src/effect-metrics.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,8 @@ export const activeHandlesByType = Metric.gauge('browserless_active_handles_by_t
134134
attributes: { unit: '{count}' },
135135
});
136136

137-
export const socketHandles = Metric.gauge('browserless_socket_handles', {
138-
description: 'Active socket handles by remote address',
139-
attributes: { unit: '{count}' },
140-
});
137+
// browserless_socket_handles removed — per-IP label creates unbounded cardinality
138+
// (also dropped at Alloy level in otelcol.processor.filter "drop_unused")
141139

142140
// Node.js runtime gauges (replaces prom-client default collectors)
143141
export const processHeapUsed = Metric.gauge('process_heap_used', {
@@ -266,20 +264,6 @@ export const gaugeCollector = Effect.gen(function*() {
266264
yield* Metric.update(activeHandlesByType.pipe(Metric.withAttributes({ type })), count);
267265
}
268266

269-
// Socket handles by remote address
270-
const socketCounts = new Map<string, number>();
271-
for (const h of (process as any)._getActiveHandles() as any[]) {
272-
if (h?.constructor?.name === 'Socket') {
273-
const remote = h.remoteAddress
274-
? `${h.remoteAddress}:${h.remotePort}`
275-
: h.destroyed ? 'destroyed' : 'no-remote';
276-
socketCounts.set(remote, (socketCounts.get(remote) || 0) + 1);
277-
}
278-
}
279-
for (const [remote, count] of socketCounts) {
280-
yield* Metric.update(socketHandles.pipe(Metric.withAttributes({ remote })), count);
281-
}
282-
283267
// Node.js runtime metrics
284268
const mem = process.memoryUsage();
285269
yield* Metric.update(processHeapUsed, mem.heapUsed);

0 commit comments

Comments
 (0)