Add `SentryAttribute.flattened`
:scroll: Description
Add SentryAttribute.flattened to allow flattening objects into separate key/value pairs of simple types. e.g.:
SentryAttribute.flattened("p", new Point(10, 20)) will add multiple attributes under the hood: p.x=10 and p.y=20.
This is currently done only for a single level, however we can expand it to more depth if needed.
:bulb: Motivation and Context
Provide API that takes care of flattening without having to manually set each attribute.
:green_heart: How did you test it?
:pencil: Checklist
- [ ] I added tests to verify the changes.
- [ ] No new PII added or SDK only sends newly added PII if
sendDefaultPIIis 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.
:crystal_ball: Next steps
| Fails | |
|---|---|
| :no_entry_sign: | Please consider adding a changelog entry for the next release. |
| Messages | |
|---|---|
| :book: | 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
- Add `SentryAttribute.flattened` ([#4417](https://github.com/getsentry/sentry-java/pull/4417))
If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description.
Generated by :no_entry_sign: dangerJS against 628254d5ef20f773fa27e63d59788b49c1f63c39
Performance metrics :rocket:
| Plain | With Sentry | Diff | |
|---|---|---|---|
| Startup time | 438.08 ms | 479.96 ms | 41.88 ms |
| Size | 1.58 MiB | 2.08 MiB | 510.55 KiB |
Baseline results on branch: feat/better-attributes-api
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| fe70d60562496bf90935ea5bbac7886f560cb75e | 401.20 ms | 545.47 ms | 144.27 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| fe70d60562496bf90935ea5bbac7886f560cb75e | 1.58 MiB | 2.08 MiB | 510.53 KiB |