Skip to content

perf(core): [Logs and Metrics Enable Flags 16] Avoid unused Metrics worker thread - #5957

Open
adinauer wants to merge 4 commits into
feat/warn-legacy-metrics-springfrom
perf/metrics-batch-thread-first-use
Open

perf(core): [Logs and Metrics Enable Flags 16] Avoid unused Metrics worker thread#5957
adinauer wants to merge 4 commits into
feat/warn-legacy-metrics-springfrom
perf/metrics-batch-thread-first-use

Conversation

@adinauer

@adinauer adinauer commented Aug 13, 2026

Copy link
Copy Markdown
Member

PR Stack (Logs and Metrics Enable Flags)


📜 Description

Defers Metrics batch processor work until the processor accepts its first Metrics item.

Before first use, empty flushes and normal or restart closes do not schedule processor work. Rejected items do not mark the processor as used. After the first accepted item, batching, flush, restart-close, and Android background behavior remain unchanged.

💡 Motivation and Context

The Metrics enable flag is gone, so every initialized SDK now creates a real Metrics batch processor. Avoid starting its executor thread for applications that never capture Metrics.

💚 How did you test it?

  • ./gradlew :sentry:test :sentry-android-core:testReleaseUnitTest
  • ./gradlew spotlessApply apiDump
  • Added lifecycle tests for construction, empty flush, close, restart close, rejected items, and first accepted use
  • Added Android coverage for background callbacks before and after first use

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

#skip-changelog

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

Avoid scheduling Metrics processor work for empty flush and close operations until the processor accepts its first item. Preserve existing batching, restart, and Android background behavior after first use.

Co-Authored-By: Claude <noreply@anthropic.com>
@sentry

sentry Bot commented Aug 13, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.52.0 (1) release

⚙️ sentry-android Build Distribution Settings

adinauer and others added 2 commits August 13, 2026 12:08
Use package visibility for executor injection so the test-only constructor does not expand the published API.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 323.53 ms 373.24 ms 49.71 ms
Size 0 B 0 B 0 B

Baseline results on branch: feat/warn-legacy-metrics-spring

Startup times

Revision Plain With Sentry Diff
f9a387b 320.24 ms 363.04 ms 42.80 ms

App size

Revision Plain With Sentry Diff
f9a387b 0 B 0 B 0 B

@adinauer
adinauer requested a review from 0xadam-brown as a code owner August 13, 2026 13:41
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.

1 participant