From c455ac290dc4e0a357dd3aa206fef44a38cb6f19 Mon Sep 17 00:00:00 2001 From: Kev Date: Sun, 26 Oct 2025 17:46:53 -0400 Subject: [PATCH 1/2] fix(tracemetrics): Bump metric buffer to 1k We've been noticing some discards from clients for likely buffer reason (primarily on python, though fixing it on both). Metrics were initially set to 100 to match logs but the size limit for a metric is ~1000x less (~1-2kb at the moment) so the memory pressure should be fine. --- packages/core/src/metrics/internal.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/metrics/internal.ts b/packages/core/src/metrics/internal.ts index 676814f4d4e6..efa204cac5a3 100644 --- a/packages/core/src/metrics/internal.ts +++ b/packages/core/src/metrics/internal.ts @@ -12,7 +12,7 @@ import { timestampInSeconds } from '../utils/time'; import { _getTraceInfoFromScope } from '../utils/trace-info'; import { createMetricEnvelope } from './envelope'; -const MAX_METRIC_BUFFER_SIZE = 100; +const MAX_METRIC_BUFFER_SIZE = 1000; /** * Converts a metric attribute to a serialized metric attribute. From 7848a3baf7b8e1e504c6de326e4255a9fe2402e7 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Tue, 28 Oct 2025 10:50:54 +0100 Subject: [PATCH 2/2] update test --- packages/core/test/lib/metrics/internal.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/test/lib/metrics/internal.test.ts b/packages/core/test/lib/metrics/internal.test.ts index bb2ddcc413c3..c0279c9a270b 100644 --- a/packages/core/test/lib/metrics/internal.test.ts +++ b/packages/core/test/lib/metrics/internal.test.ts @@ -249,12 +249,12 @@ describe('_INTERNAL_captureMetric', () => { const scope = new Scope(); scope.setClient(client); - // Fill the buffer to max size (100 is the MAX_METRIC_BUFFER_SIZE constant) - for (let i = 0; i < 100; i++) { + // Fill the buffer to max size (1000 is the MAX_METRIC_BUFFER_SIZE constant) + for (let i = 0; i < 1000; i++) { _INTERNAL_captureMetric({ type: 'counter', name: `metric.${i}`, value: i }, { scope }); } - expect(_INTERNAL_getMetricBuffer(client)).toHaveLength(100); + expect(_INTERNAL_getMetricBuffer(client)).toHaveLength(1000); // Add one more to trigger flush _INTERNAL_captureMetric({ type: 'counter', name: 'trigger.flush', value: 999 }, { scope });