Skip to content

feat(metrics): [Micrometer 5] Add ignored metric names - #6155

Draft
adinauer wants to merge 5 commits into
feat/micrometer-spring-bootfrom
feat/micrometer-ignored-metrics
Draft

adinauer wants to merge 5 commits into
feat/micrometer-spring-bootfrom
feat/micrometer-ignored-metrics

Conversation

@adinauer

@adinauer adinauer commented Sep 23, 2026

Copy link
Copy Markdown
Member

PR Stack (Micrometer)


📜 Description

Add options.getMetrics().setIgnoredMetrics(...) and addIgnoredMetric(...) to filter final metric names using case-insensitive exact matches or full regular-expression matches.

  • Filter in the core metrics API before allocating events or processing scope attributes. This applies to manual metrics and integrations.
  • Reuse the matcher in a Sentry-local Micrometer MeterFilter to avoid registering ignored meters. Only deny multi-output meters when all possible exported names are ignored; the core filter remains authoritative.
  • Support metrics.ignored-metrics in external configuration, io.sentry.metrics.ignored-metrics in the Android manifest, and sentry.metrics.ignored-metrics in Spring Boot properties.
  • Default Spring Boot 2/3/4 to ignoring logback.events and log4j2.events when the list is unset. Apply defaults before user callbacks; explicit lists replace the defaults and empty lists disable filtering. Plain Java and Android remain unfiltered by default.

Other Micrometer registries and actual logging are unaffected. Name filters also apply to manually recorded Sentry metrics with the same names. Configure filters before meter registration: clearing a filter later does not reactivate a previously returned no-op meter. Intentional ignores do not produce client reports.

💡 Motivation and Context

Micrometer logging counters forward each log event individually through this registry. A Logback load test at 100,000 logs/sec lost approximately 98% of both logging and independent business increments through the shared metrics queue. Explicit logging-name filters preserved all 2,000 business increments during a 20-second, two-million-log workload, with zero client-reported drops and allocation near the no-Sentry baseline.

The declarative option avoids per-event callback overhead and provides early Micrometer filtering without a Boot-wide filter that would also affect other exporters. Spring Boot defaults protect the common Actuator setup while allowing customers to replace or clear the exclusions.

💚 How did you test it?

  • 1,014 selected tests passed across core, Micrometer, Android manifest parsing, and Spring Boot 2/3/4.
  • Verified matching, external/manifest configuration, final-name conversion, conservative multi-output filtering, core filtering, Boot defaults, explicit empty/custom properties, callback overrides, and coexistence with another registry.
  • ./gradlew spotlessApply apiDump and ./gradlew spotlessCheck apiCheck passed.
  • Ran 12 real Boot 3.5 / Actuator / Logback load cases comparing no Sentry, Sentry without ignores, and Sentry with explicit logging-name ignores at 1k, 10k, and 100k logs/sec, with a reverse-order repeat at 100k. All filtered runs delivered every business increment with zero drops. This load comparison predates enabling the Boot defaults; default behavior is covered by the Boot tests. Log4j2 was not separately load-tested.

📝 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.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

Review the public option API and add the filtering/defaults guidance to the generic Java and Spring Boot documentation.

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

Let applications suppress noisy metrics before event processing using
case-insensitive names or full regular expressions. Support external
configuration, Android manifest metadata, and Spring Boot properties.

Default Spring Boot applications to excluding Logback and Log4j2 counters
to prevent logging-driven queue overload. Preserve explicit lists, including
empty lists, and allow user callbacks to append, replace, or clear defaults.
Keep plain Java and Android defaults unfiltered.

Reuse the core matcher in a Sentry-local Micrometer MeterFilter to avoid
registration and recording overhead without affecting other registries.
Preserve partial exports for meters with multiple possible output names.

Cover configuration, matching, name conversion, and filtering behavior
with tests. Verify that filtering logging counters prevents queue overflow
and preserves business metrics during a 100,000-log-per-second workload.

Co-Authored-By: Codex <noreply@openai.com>
@github-actions

github-actions Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 99384d9

@sentry

sentry Bot commented Sep 23, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

adinauer and others added 4 commits September 23, 2026 14:43
Link the ignored-metrics feature entry and Spring Boot defaults to PR #6155.

Co-Authored-By: Codex <noreply@openai.com>
Merge the Spring Boot registry scopes change from #6116 into #6155.
Use the same injected scopes for registration filtering and recording so
custom scopes do not accidentally inherit global ignored-metric options.

Resolve test imports, supply options in injected-scope fixtures, and cover
filtering with distinct global and injected ignore lists. Preserve the
existing logging defaults and explicit override behavior.

Refs #6116
Refs #6155
Co-Authored-By: Claude <noreply@anthropic.com>
Merge the Boot 3 and Boot 4 sample endpoints and dual-registry system tests
from #6116 into the ignored-metrics branch. Keep the top of the stack in
sync without rewriting its history.

Verify all 18 metrics system tests against Boot 2, 3, and 4 with the
ignored-metrics defaults applied. Formatting and API checks also pass.

Refs #6116
Refs #6155
Co-Authored-By: Claude <noreply@anthropic.com>
Apply the default logging metric exclusions only when the Micrometer
integration is enabled. This keeps manual metrics unchanged for Spring
Boot applications that have not opted into Micrometer export.

Cover disabled and enabled behavior across all supported Boot versions
and align the integration documentation with the scoped defaults.

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

This branch has not been deployed

No deployments
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