Skip to content

Conversation

@adinauer
Copy link
Member

@adinauer adinauer commented Dec 22, 2025

📜 Description

Add options for Metrics to SentryOptions:

  • SentryOptions.getMetrics().setEnabled(true)
  • SentryOptions.getMetrics().setBeforeSend(...)

💡 Motivation and Context

💚 How did you test it?

📝 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.

🔮 Next steps

Copy link
Member Author

adinauer commented Dec 22, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Dec 22, 2025

Fails
🚫 Please consider adding a changelog entry for the next release.
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- [Trace Metrics 1] Metrics Options ([#4980](https://github.com/getsentry/sentry-java/pull/4980))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 857a7aa

public static final class Metrics {

/** Whether Sentry Metrics feature is enabled and metrics are sent to Sentry. */
private boolean enable = false;
Copy link
Member Author

Choose a reason for hiding this comment

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

changed to true in a follow up PR

*/
// TODO replace with SentryMetric
@Nullable
Object execute(@NotNull Object metric);
Copy link
Member Author

Choose a reason for hiding this comment

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

Signature updated in follow-up PRs

Copy link
Member

Choose a reason for hiding this comment

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

do we need any kind of hint here? just wondering if it makes sense to add it now to not break this API in the future in case we need it (i'm imagining if we start sending default metrics like Android's AppExitReasons, the hint could be a good place to expose some information along)

this.logs = logs;
}

@ApiStatus.Experimental
Copy link
Member Author

Choose a reason for hiding this comment

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

New APIs should not be marked Experimental

@adinauer adinauer force-pushed the 12-17-metrics_options branch from 3513eaa to 857a7aa Compare December 22, 2025 13:41
@github-actions
Copy link
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 311.43 ms 367.38 ms 55.95 ms
Size 1.58 MiB 2.13 MiB 559.66 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
33a08cc 267.08 ms 340.45 ms 73.37 ms
fc5ccaf 256.80 ms 322.36 ms 65.56 ms
fc5ccaf 276.52 ms 370.46 ms 93.93 ms
ee747ae 386.94 ms 431.43 ms 44.49 ms
fcec2f2 311.35 ms 384.94 ms 73.59 ms
cf708bd 408.35 ms 458.98 ms 50.63 ms
b3d8889 420.46 ms 453.71 ms 33.26 ms
ed33deb 337.52 ms 484.06 ms 146.54 ms
dba088c 365.46 ms 366.31 ms 0.85 ms
9fbb112 361.43 ms 427.57 ms 66.14 ms

App size

Revision Plain With Sentry Diff
33a08cc 1.58 MiB 2.12 MiB 555.28 KiB
fc5ccaf 1.58 MiB 2.13 MiB 557.54 KiB
fc5ccaf 1.58 MiB 2.13 MiB 557.54 KiB
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB
fcec2f2 1.58 MiB 2.12 MiB 551.51 KiB
cf708bd 1.58 MiB 2.11 MiB 539.71 KiB
b3d8889 1.58 MiB 2.10 MiB 535.07 KiB
ed33deb 1.58 MiB 2.13 MiB 559.52 KiB
dba088c 1.58 MiB 2.13 MiB 558.99 KiB
9fbb112 1.58 MiB 2.11 MiB 539.18 KiB

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