Skip to content

feat(dart): Remove need for enableLogs and enableMetrics v10 - #3983

Merged
buenaflor merged 4 commits into
v10-branchfrom
feat/remove-telemetry-enable-flags-v10
Aug 31, 2026
Merged

buenaflor merged 4 commits into
v10-branchfrom
feat/remove-telemetry-enable-flags-v10

Conversation

@buenaflor

@buenaflor buenaflor commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

Removes enableLogs and enableMetrics from SentryOptions. Logs and metrics are always captured at the Dart layer (still no auto-instrumentation), and manual Sentry.logger / Sentry.metrics calls stay always-on.

LoggingIntegration is the only automatic log source, and adding it is now the whole opt-in: it forwards records at or above minSentryLogLevel as structured logs, with no second flag. Raise that threshold, or set it to Level.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, Cocoa enableLogs/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 lifecycle
  • packages/flutter — load contexts, replay telemetry, widgets binding observer
  • packages/logging — logging integration, including minSentryLogLevel: Level.OFF forwarding nothing
  • Cocoa unit test: update(options:with: [:]) leaves enableLogs and enableMetrics true
  • dart analyze clean on touched files

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPii is enabled
  • I updated the docs if needed
  • All tests passing
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec
  • No breaking changes

🔮 Next steps

Docs need updating to drop options.enableLogs / options.enableMetrics from setup snippets, and to note that adding the logging integration forwards logs on its own.

Changelog Entry

Remove the enableLogs and enableMetrics options. Logs and metrics are now always enabled and can no longer be disabled through SentryOptions. Remove any options.enableLogs / options.enableMetrics assignments from your SDK init. If you use the logging integration, it now forwards log records as Sentry logs as soon as it is added — raise minSentryLogLevel, or set it to Level.OFF, to opt out.

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]>
@buenaflor
buenaflor requested a review from denrase as a code owner August 25, 2026 08:38
Copilot AI lite review requested due to automatic review settings August 25, 2026 08:38
@github-actions

github-actions Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Features

  • Remove the enableLogs and enableMetrics options. Logs and metrics are now always enabled and can no longer be disabled through SentryOptions. Remove any options.enableLogs / options.enableMetrics assignments from your SDK init. If you use the logging integration, it now forwards log records as Sentry logs as soon as it is added — raise minSentryLogLevel, or set it to Level.OFF, to opt out. by buenaflor in #3983
  • (replay) Mask SensitiveContent by default by buenaflor in #3973

Fixes

  • Sampling now runs after beforeSend instead of before it, so ignoreErrors, ignored exception types, event processors and beforeSend all take precedence over the sampleRate decision. An event dropped by beforeSend is now reported as a before_send discard rather than a sample_rate one, and beforeSend now runs for events that are later sampled out. (#3855) by buenaflor in #3955
  • (http) Align HTTP client error type and value by buenaflor in #3934

Internal Changes

Flutter

  • Default standalone app start tracing by buenaflor in #3981
  • Migrate the Android plugin to Flutter's built-in Kotlin. sentry_flutter no longer applies the Kotlin Gradle Plugin itself, which silences Flutter 3.44's warning about plugins applying KGP and unblocks apps moving to AGP 9. by buenaflor in #3961
  • Made with Cursor by buenaflor in #3961

🤖 This preview updates automatically when you update the PR.

@codecov

codecov Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 6 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (v10-branch@b2f8bd2). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...event_processor/enricher/enricher_integration.dart 69.23% 4 Missing ⚠️
...ib/src/integrations/load_contexts_integration.dart 84.61% 2 Missing ⚠️
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           
Flag Coverage Δ
sentry 88.39% <69.23%> (?)
sentry_dio 97.95% <ø> (?)
sentry_drift 93.63% <ø> (?)
sentry_file 64.41% <ø> (?)
sentry_firebase_remote_config 100.00% <ø> (?)
sentry_flutter 92.44% <84.61%> (?)
sentry_grpc 99.11% <ø> (?)
sentry_hive 76.37% <ø> (?)
sentry_isar 73.88% <ø> (?)
sentry_link 22.04% <ø> (?)
sentry_logging 97.01% <100.00%> (?)
sentry_sqflite 88.88% <ø> (?)
sentry_supabase 97.48% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 / enableMetrics from SentryOptions and 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.enableLogs and SentryOptions.enableMetrics is a breaking change; the PR title includes feat(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 / .enableMetrics references under packages/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 indicate logs/metrics getters 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.

@buenaflor buenaflor changed the title feat(dart)!: Remove enableLogs and enableMetrics feat(dart)!: Remove enableLogs and enableMetrics v10 Aug 25, 2026
@buenaflor
buenaflor requested a review from adinauer August 25, 2026 12:54
@buenaflor

Copy link
Copy Markdown
Contributor Author

@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]>
buenaflor and others added 2 commits August 26, 2026 12:57
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]>
@buenaflor buenaflor changed the title feat(dart)!: Remove enableLogs and enableMetrics v10 feat(dart): Remove need for enableLogs and enableMetrics v10 Aug 31, 2026
@buenaflor
buenaflor merged commit 654c375 into v10-branch Aug 31, 2026
142 of 143 checks passed
@buenaflor
buenaflor deleted the feat/remove-telemetry-enable-flags-v10 branch August 31, 2026 12:23
@buenaflor buenaflor mentioned this pull request Sep 29, 2026
2 tasks
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