-
-
Notifications
You must be signed in to change notification settings - Fork 465
feat(metrics): [Trace Metrics 1] Metrics Options #4980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Instructions and example for changelogPlease add an entry to 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 |
| public static final class Metrics { | ||
|
|
||
| /** Whether Sentry Metrics feature is enabled and metrics are sent to Sentry. */ | ||
| private boolean enable = false; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO metrics are much more similar to logs where we also do not have a hint. Given that the volume of metrics could be way higher than for events I'm fine with not having hints. We can revisit before unmarking the options as experimental too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're planning to release as non experimental right away. IIRC hints were a bit odd on logs due to batching. I can do a quick experiment whether adding Hint is simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple things I found:
- Adding
HinttoEventProcessorandmetrics.beforeSendcan easily be done - Passing
HinttoITransportis more tricky since I wouldn't know how to combine / choseHintwhen there's a batch of metrics that each have their ownHint. So I'd suggest we skip passingHinttoITransportfor now. - I'm not quite sure where to add
HinttoIMetricsApimethod signatures.- Could add it as a param, making the overload pyramid worse
- Could also add it to
SentryMetricsParams
| this.logs = logs; | ||
| } | ||
|
|
||
| @ApiStatus.Experimental |
There was a problem hiding this comment.
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
3513eaa to
857a7aa
Compare
Performance metrics 🚀
|
| 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 |
markushi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a tiny nit about using final for a few method arguments.
| */ | ||
| // TODO replace with SentryMetric | ||
| @Nullable | ||
| Object execute(@NotNull Object metric); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO metrics are much more similar to logs where we also do not have a hint. Given that the volume of metrics could be way higher than for events I'm fine with not having hints. We can revisit before unmarking the options as experimental too.
857a7aa to
e156d3c
Compare
|
@sentry review |
|
cursor review |
There was a problem hiding this 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!
* Metrics Options * MetricsApi stub * Add transport types for metrics * Enable metrics by default * Format code * Add batch processor for Metrics * Wire up Metrics parts * Metrics counter basic API * Metrics Count API * Metrics Distribution API * Metrics Gauge API * Metrics Envelope item deserialization * Record client report for discarded metrics envelope item * Metrics external options * Metrics Manifest options for Android * Android Metrics batch processor and factory * Only send user attributes if sendDefaultPii is true * Remove Experimental Annotation from Metrics Options * Add unit tests for Metrics * Create SentryMetricsParameters for Metrics * Use uv for managing python version * fix * Add device and OS attributes to metrics * Add AI rules files for Metrics (and update feature flags rule) * Close and flush MetricsBatchProcessor from SentryClient * fix * Add E2E tests for Metrics * Final keyword in Metrics methods * Add Hint to Metrics * SentryMetricsParameters create shortcut for attributes map * Automatically use SentryOptions.Metrics.BeforeSendMetricCallback Spring beans * Rename sample API param, remove sleep * Create MetricsUnit constants * Format code * Metrics Options (#4980) * feat(metrics): [Trace Metrics 2] MetricsApi stub (#4981) * Metrics Options * MetricsApi stub * More PR review changes (#5028) * Some more PR review changes * Format code --------- Co-authored-by: Sentry Github Bot <[email protected]> * changelog * non nullable trace id * error log now says metric instead of log --------- Co-authored-by: Sentry Github Bot <[email protected]> Co-authored-by: lcian <[email protected]>

📜 Description
Add options for Metrics to
SentryOptions:SentryOptions.getMetrics().setEnabled(true)SentryOptions.getMetrics().setBeforeSend(...)💡 Motivation and Context
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps