Repository navigation
feat(dart): Remove need for enableLogs and enableMetrics v10 - #3983
Conversation
Logs and metrics are now always captured. Native Android and Cocoa init enable both explicitly so collection matches the Dart layer. Co-Authored-By: Cursor <[email protected]>
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Features
Fixes
Internal ChangesFlutter
🤖 This preview updates automatically when you update the PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v10-branch #3983 +/- ##
=============================================
Coverage ? 88.51%
=============================================
Files ? 346
Lines ? 12417
Branches ? 0
=============================================
Hits ? 10991
Misses ? 1426
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
There was a problem hiding this comment.
Pull request overview
Removes the enableLogs / enableMetrics flags from the Dart SentryOptions public API and updates Dart/Flutter/Logging integrations so logs and metrics are always processed at the Dart layer, while explicitly enabling the corresponding native toggles during Flutter native initialization.
Changes:
- Removed
enableLogs/enableMetricsfromSentryOptionsand eliminated all gating that dropped logs/metrics based on those flags. - Updated integrations/pipelines (Dart core, Flutter LoadContexts, sentry_logging) and adjusted tests to reflect “always enabled” behavior.
- Updated Flutter native init to explicitly enable logs/metrics on Android (JNI options) and Cocoa (SentryOptions).
Standards (repo conventions / API surface)
- Public API: removing
SentryOptions.enableLogsandSentryOptions.enableMetricsis a breaking change; the PR title includesfeat(dart)!, which matches that reality. - Test updates are aligned with the new invariant (callbacks always register; pipelines don’t drop items up-front).
Spec (vs PR description)
- Matches the described intent: Dart-layer always captures logs/metrics (still no auto-instrumentation), and Flutter native init turns on native-side flags explicitly on Android/Cocoa.
Correctness (runtime safety)
- Dart-side changes appear mechanically consistent: all remaining
.enableLogs/.enableMetricsreferences underpackages/dart,packages/logging, and Dart Flutter code are removed. - Android JNI update uses the same “get nested option object +
releasedBy(arena)” pattern already used in the file (e.g.,sessionReplay), and the generated bindings indicatelogs/metricsgetters are non-null and require release, so the new code path is consistent with the binding contract.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/logging/test/logging_integration_test.dart | Removes enableLogs gating in tests; asserts forwarding is controlled by minSentryLogLevel. |
| packages/logging/lib/src/logging_integration.dart | Removes runtime gating on SentryOptions.enableLogs; forwards based on level threshold only. |
| packages/flutter/test/widgets_binding_observer_test.dart | Drops enableLogs setup since logs are always enabled at Dart layer. |
| packages/flutter/test/integrations/replay_telemetry_integration_test.dart | Drops enableLogs setup since logs are always enabled at Dart layer. |
| packages/flutter/test/integrations/load_contexts_integration_test.dart | Updates assertions and removes disabled-path tests; callbacks now always registered. |
| packages/flutter/lib/src/native/java/sentry_native_java_init.dart | Explicitly enables Android native logs + metrics via JNI options. |
| packages/flutter/lib/src/integrations/load_contexts_integration.dart | Always registers log/metric lifecycle callbacks (no flag gates). |
| packages/flutter/example/lib/main.dart | Removes example usage of options.enableLogs. |
| packages/flutter/example/ios/RunnerTests/SentryFlutterTests.swift | Adds a regression test asserting update keeps native enableLogs/enableMetrics enabled. |
| packages/flutter/darwin/sentry_flutter/Sources/sentry_flutter/SentryFlutter.swift | Forces Cocoa enableLogs/enableMetrics on during native options update. |
| packages/dart/test/telemetry/processing/processor_test.dart | Removes enableLogs/enableMetrics fixture wiring; processor always routes logs/metrics. |
| packages/dart/test/telemetry/metric/metrics_setup_integration_test.dart | Removes enabled/disabled branching tests; metrics setup always applies unless custom non-noop is set. |
| packages/dart/test/telemetry/metric/metric_capture_pipeline_test.dart | Removes disabled-path test and fixture flag wiring. |
| packages/dart/test/telemetry/log/logger_setup_integration_test.dart | Removes enabled/disabled branching tests; logger setup always applies unless custom non-noop is set. |
| packages/dart/test/telemetry/log/log_capture_pipeline_test.dart | Removes disabled-path test and fixture flag wiring. |
| packages/dart/test/sentry_options_test.dart | Removes tests asserting default values for removed flags. |
| packages/dart/test/sentry_client_test.dart | Drops enableLogs setup; behavior now unconditional for log capture paths. |
| packages/dart/test/sentry_client_sdk_lifecycle_test.dart | Drops enableLogs setup; lifecycle callback triggering no longer depends on flags. |
| packages/dart/test/sentry_client_lifecycle_test.dart | Drops enableLogs setup; lifecycle callback triggering no longer depends on flags. |
| packages/dart/test/event_processor/enricher/enricher_integration_test.dart | Removes flag-dependent branches; callbacks now always register for logs/metrics. |
| packages/dart/lib/src/telemetry/metric/metrics_setup_integration.dart | Removes early-return that skipped metrics setup when disabled. |
| packages/dart/lib/src/telemetry/metric/metric_capture_pipeline.dart | Removes early-return that dropped metrics when disabled. |
| packages/dart/lib/src/telemetry/log/logger_setup_integration.dart | Removes early-return that skipped logger setup when disabled. |
| packages/dart/lib/src/telemetry/log/log_capture_pipeline.dart | Removes early-return that dropped logs when disabled. |
| packages/dart/lib/src/sentry_options.dart | Removes the enableLogs / enableMetrics fields from SentryOptions. |
| packages/dart/lib/src/event_processor/enricher/enricher_integration.dart | Always registers log/metric lifecycle callbacks (no flag gates). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@adinauer just tagged you here in case you want to take a quick look since you also did this for java 👍 |
Gate Sentry.logger forwarding behind enableLogs, defaulting to false to match Java Logback/Timber. Breadcrumbs and events are unchanged. Co-Authored-By: Cursor <[email protected]>
Reverts 41a4270. With SentryOptions.enableLogs gone, a local flag would be a second opt-in on top of adding the integration, which the logs policy rules out. sentry-java has no per-integration boolean either -- Logback, Log4j2, JUL and Timber gate on the global flag plus a level threshold. Adding the integration is the opt-in; minSentryLogLevel, including Level.OFF, is the way to stop forwarding. Co-Authored-By: Cursor <[email protected]>
📜 Description
Removes
enableLogsandenableMetricsfromSentryOptions. Logs and metrics are always captured at the Dart layer (still no auto-instrumentation), and manualSentry.logger/Sentry.metricscalls stay always-on.LoggingIntegrationis the only automatic log source, and adding it is now the whole opt-in: it forwards records at or aboveminSentryLogLevelas structured logs, with no second flag. Raise that threshold, or set it toLevel.OFF, to keep breadcrumbs and events without logs. This matches sentry-java, where Logback, Log4j2, JUL and Timber pair a level threshold with the global flag and have no per-integration boolean.Native init now enables both explicitly: Android
logs/metrics, CocoaenableLogs/enableMetrics. sentry-native has no equivalent options.v10 port of #3964, adapted for Cocoa 9.21 top-level options and the JNI property accessors. The 9.x counterpart is #3982, which keeps the options but stops them gating the manual APIs.
💡 Motivation and Context
Logs and metrics should be on by default at the SDK options layer. Native SDKs still default logs off, so Flutter has to turn them on at init.
The logs policy also rules out a real double opt-in — users should not have to both flip a flag and add an integration. With the global option gone, the integration itself is the opt-in.
💚 How did you test it?
packages/dart— options, pipelines, setup integrations, enricher, client lifecyclepackages/flutter— load contexts, replay telemetry, widgets binding observerpackages/logging— logging integration, includingminSentryLogLevel: Level.OFFforwarding nothingupdate(options:with: [:])leavesenableLogsandenableMetricstruedart analyzeclean on touched files📝 Checklist
sendDefaultPiiis enabled🔮 Next steps
Docs need updating to drop
options.enableLogs/options.enableMetricsfrom setup snippets, and to note that adding the logging integration forwards logs on its own.Changelog Entry
Remove the
enableLogsandenableMetricsoptions. Logs and metrics are now always enabled and can no longer be disabled throughSentryOptions. Remove anyoptions.enableLogs/options.enableMetricsassignments from your SDK init. If you use the logging integration, it now forwards log records as Sentry logs as soon as it is added — raiseminSentryLogLevel, or set it toLevel.OFF, to opt out.