Skip to content

Conversation

@philprime
Copy link
Member

@philprime philprime commented Dec 2, 2025

This PR is part of a merge-chain and should be merged one-by-one into main as soon as all of them are ready to be merged:

  1. feat(metrics): Add integration with installation by SDK #6956
  2. feat(metrics): Add implementation for metrics envelope item #6960
  3. feat(metrics): Add public API to collect count, distribution and gauge #6957

📜 Description

This pull request introduces a new metrics integration to the Sentry SDK for Swift, allowing users to enable metrics collection and reporting via the SDK. The changes include the addition of the enableMetrics option, implementation of the metrics integration, updates to the SDK configuration, and new tests to verify the integration. The project structure is also updated to include the new integration and its tests.

Metrics Integration Feature:

  • Added a new enableMetrics option to SentryOptions, allowing users to enable or disable metrics collection. [1] [2]
  • Implemented MetricsIntegration, which is installed when enableMetrics is set to true. [1] [2]
  • Updated the SDK wrapper and options validation to support the new enableMetrics option. [1] [2]
  • Updated the enabled features builder to include "metrics" when the feature is enabled.

💡 Motivation and Context

Closes #6954

💚 How did you test it?

  • Added unit tests based on the existing option enableLogs
  • Added unit tests based on the session replay integration
  • Added option to enable metrics to run arguments in scheme
    • Enabled the option, ran the macOS sample app and checked that the "Integration initialized" log message shows up.

📝 Checklist

You have to check all boxes before merging:

  • 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. → [Metrics] Add documentation for feature #7045
  • 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.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

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

Generated by 🚫 dangerJS against e61661b

@philprime philprime self-assigned this Dec 2, 2025
@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.115%. Comparing base (771f76a) to head (e61661b).
⚠️ Report is 7 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #6956       +/-   ##
=============================================
+ Coverage   84.933%   85.115%   +0.182%     
=============================================
  Files          457       461        +4     
  Lines        27624     28043      +419     
  Branches     12144     12339      +195     
=============================================
+ Hits         23462     23869      +407     
+ Misses        4119      3916      -203     
- Partials        43       258      +215     
Files with missing lines Coverage Δ
SentryTestUtils/Sources/TestOptions.swift 100.000% <100.000%> (ø)
Sources/Swift/Core/Integrations/Integrations.swift 100.000% <100.000%> (ø)
...es/Swift/Helper/SentryEnabledFeaturesBuilder.swift 100.000% <100.000%> (ø)
...ntegrations/Metrics/SentryMetricsIntegration.swift 100.000% <100.000%> (ø)
Sources/Swift/SentryExperimentalOptions.swift 75.000% <100.000%> (+8.333%) ⬆️

... and 40 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 771f76a...e61661b. Read the comment docs.

@philprime philprime marked this pull request as draft December 2, 2025 13:57
@philprime
Copy link
Member Author

@cursor review
@sentry review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no bugs!


@philprime philprime force-pushed the philprime/metrics-bootstrap branch from a5056fb to 1210307 Compare December 2, 2025 15:13
- Introduced new test file `SentryItemBatcherTests.swift` to validate the behavior of the `SentryItemBatcher`.
- Added tests for various scenarios including item addition, buffer size limits, timeout handling, and attribute enrichment.
- Updated project configuration to include the new test file in the build settings.
Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

LGTM, when only merging this to main as pointed out in #6956 (comment).

@philprime
Copy link
Member Author

After reconsideration and learnings while working on #6957 I decided that I will move this feature to be marked as "experimental" first to keep some leeway to react if the public API using Swift Language features such as ExpressibleByInt is not working as expected.

@philprime philprime added the dontmerge A branch that absolutely should not be merged while this label is applied. label Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dontmerge A branch that absolutely should not be merged while this label is applied. ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Metrics] Add integration bootstrapping

3 participants