Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add server runtime metrics aggregator #9894

Merged
merged 2 commits into from
Dec 21, 2023

Conversation

anonrig
Copy link
Contributor

@anonrig anonrig commented Dec 18, 2023

Implements

  • 10 Second Bucketing: SDKs are required to bucket into 10 second intervals (rollup in seconds) which is the current lower bound of metric accuracy.
  • Flush Shift: SDKs are required to shift the flush interval by random() * rollup_in_seconds. That shift is determined once per startup to create jittering.
  • Force flush: an SDK is required to perform force flushing ahead of scheduled time if the memory pressure is too high. There is no rule for this other than that SDKs should be tracking abstract aggregation complexity (eg: a counter only carries a single float, whereas a distribution is a float per emission).

Caveats

  • Force flush requires Node.js 14+ support (FinalizationRegistry). I recommend leaving it after v8 release to make the implementation a lot easier.

@anonrig anonrig force-pushed the add-server-runtime-metrics-aggregator branch from 4c19afd to 29c6cf7 Compare December 18, 2023 16:56
Copy link
Contributor

github-actions bot commented Dec 18, 2023

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 75.89 KB (+0.1% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 67.25 KB (+0.12% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 60.87 KB (+0.12% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 31.83 KB (+0.22% 🔺)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 30.39 KB (+0.37% 🔺)
@sentry/browser - Webpack (gzipped) 22.09 KB (+0.6% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 73.32 KB (+0.11% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 64.99 KB (+0.13% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 31.13 KB (+0.17% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped) 23.13 KB (+0.53% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 203.79 KB (+0.11% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 93.67 KB (+0.23% 🔺)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 68.6 KB (+0.6% 🔺)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 34.08 KB (+0.14% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 67.66 KB (+0.11% 🔺)
@sentry/react - Webpack (gzipped) 22.12 KB (+0.6% 🔺)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 84.31 KB (+0.09% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 48.95 KB (+0.15% 🔺)
@sentry-internal/feedback - Webpack (gzipped) 16.6 KB (0%)

@anonrig anonrig force-pushed the add-server-runtime-metrics-aggregator branch 7 times, most recently from 0beba1e to dfdcc8b Compare December 19, 2023 01:09
@anonrig anonrig requested review from a team, lforst and AbhiPrasad and removed request for a team December 19, 2023 01:09
@anonrig anonrig marked this pull request as ready for review December 19, 2023 01:09
@anonrig anonrig force-pushed the add-server-runtime-metrics-aggregator branch 2 times, most recently from 70ab0a3 to 15436cd Compare December 19, 2023 01:39
@lforst
Copy link
Member

lforst commented Dec 19, 2023

Could you rename the simple/browser-aggregator with git mv so we have a cleaner diff? Thanks!

@anonrig anonrig force-pushed the add-server-runtime-metrics-aggregator branch from 15436cd to 1b4451c Compare December 19, 2023 13:34
@anonrig
Copy link
Contributor Author

anonrig commented Dec 19, 2023

Could you rename the simple/browser-aggregator with git mv so we have a cleaner diff? Thanks!

@lforst It's not a 1 to 1 move because I also had to do a refactoring on the bucket value type.

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome!!

packages/core/src/metrics/aggregator.ts Outdated Show resolved Hide resolved
@@ -30,7 +30,7 @@ export function createMetricEnvelope(
return createEnvelope<StatsdEnvelope>(headers, [item]);
}

function createMetricEnvelopeItem(metricBucketItems: Array<MetricBucketItem>): StatsdItem {
function createMetricEnvelopeItem(metricBucketItems: MetricBucketItem[]): StatsdItem {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so nit, I always prefer Array<T> because of https://tkdodo.eu/blog/array-types-in-type-script, but this is fine as well.

Maybe we should enforce one vs. other with lint rule.

@lforst lforst changed the title feat: add server runtime metrics aggregator feat: Add server runtime metrics aggregator Dec 21, 2023
@anonrig anonrig force-pushed the add-server-runtime-metrics-aggregator branch 2 times, most recently from 699863e to 44854d7 Compare December 21, 2023 19:43
@anonrig anonrig force-pushed the add-server-runtime-metrics-aggregator branch from 44854d7 to c38fb53 Compare December 21, 2023 19:44
@anonrig anonrig enabled auto-merge (squash) December 21, 2023 19:54
@anonrig anonrig merged commit 7f8eca7 into develop Dec 21, 2023
94 of 95 checks passed
@anonrig anonrig deleted the add-server-runtime-metrics-aggregator branch December 21, 2023 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants