sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

feat(metrics): Add public API to collect count, distribution and gauge

Open philprime opened this issue 3 weeks ago • 2 comments

:scroll: Description

This pull request introduces a new metrics API to the codebase, allowing clients to record custom metrics such as counts, distributions, and gauges. The API is exposed via the SentrySDK.metrics property and is designed for future extensibility, though the current implementation is a no-op.

This PR also adds an example UI to manually collect metrics in iOS-Swift.

:bulb: Motivation and Context

Closes #6949

:green_heart: How did you test it?

  • Added unit tests

:pencil: Checklist

You have to check all boxes before merging:

  • [X] I added tests to verify the changes.
  • [X] 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.
  • [X] Review from the native team if needed.
  • [ ] No breaking change or entry added to the changelog.
  • [X] No breaking change for hybrid SDKs or communicated to hybrid SDKs.

philprime avatar Dec 02 '25 13:12 philprime

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

Generated by :no_entry_sign: dangerJS against 2cd3b89b3531cdee8770a3f3d1d7a174d7929a4d

github-actions[bot] avatar Dec 02 '25 13:12 github-actions[bot]

:warning: JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload. For more help, visit our troubleshooting guide.

codecov[bot] avatar Dec 02 '25 13:12 codecov[bot]

@sentry review

philprime avatar Dec 18 '25 10:12 philprime

Performance metrics :rocket:

  Plain With Sentry Diff
Startup time 1209.52 ms 1247.46 ms 37.94 ms
Size 24.14 KiB 1.05 MiB 1.02 MiB

Baseline results on branch: philprime/metrics-envelope

Startup times

Revision Plain With Sentry Diff
63535b82c02e659862de227590d66775f51b534a 1228.64 ms 1255.27 ms 26.63 ms
34e473acf0c2231f4c7aecda08469c51f6b8054e 1195.53 ms 1222.53 ms 27.00 ms
f1ee7f4a4a468d79e01d7f9f3841307824f95636 1221.29 ms 1248.16 ms 26.87 ms

App size

Revision Plain With Sentry Diff
63535b82c02e659862de227590d66775f51b534a 24.14 KiB 1.04 MiB 1.01 MiB
34e473acf0c2231f4c7aecda08469c51f6b8054e 24.14 KiB 1.04 MiB 1.01 MiB
f1ee7f4a4a468d79e01d7f9f3841307824f95636 24.14 KiB 1.04 MiB 1.01 MiB

Previous results on branch: philprime/metrics-public-api

Startup times

Revision Plain With Sentry Diff
a35c105f6b0455c37eb2906b0939e4b54b0f4852 1220.52 ms 1247.74 ms 27.22 ms
a7831e5affca02e149d7a4f3849a625cd9b6e31d 1210.38 ms 1244.09 ms 33.71 ms

App size

Revision Plain With Sentry Diff
a35c105f6b0455c37eb2906b0939e4b54b0f4852 24.14 KiB 1.05 MiB 1.02 MiB
a7831e5affca02e149d7a4f3849a625cd9b6e31d 24.14 KiB 1.05 MiB 1.02 MiB

github-actions[bot] avatar Dec 18 '25 11:12 github-actions[bot]

Converted back to draft until I properly handle the typing of the integrations

philprime avatar Dec 18 '25 13:12 philprime

@sentry review @cursor review

philprime avatar Dec 18 '25 14:12 philprime