docs(metrics): Explain metric unit API design - #6087
Open
adinauer wants to merge 2 commits into
Open
Conversation
Document why metrics accept string units rather than reusing MeasurementUnit. This preserves the supported-unit distinction and lets older SDK versions send newly introduced units. Co-Authored-By: Claude <noreply@anthropic.com>
adinauer
marked this pull request as ready for review
September 10, 2026 08:12
adinauer
requested review from
0xadam-brown,
markushi,
romtsn and
runningcode
as code owners
September 10, 2026 08:12
runningcode
reviewed
Sep 10, 2026
| * <p>These constants represent the API names of measurement units that can be used with metrics. | ||
| * Metrics APIs intentionally accept strings instead of {@link io.sentry.MeasurementUnit} because it | ||
| * contains units that metrics do not support. Strings also let older SDK versions use units | ||
| * introduced after their release. |
Contributor
There was a problem hiding this comment.
So when should we use MetricsUnit and when should we use MeasurementUnit ? And same for customers?
Member
Author
There was a problem hiding this comment.
MetricsUnitis for the Metrics product andSentry.metrics(),scope.metrics()(i.e.IMetricsApi) API.MeasurementUnitis for transaction / span measurement APIs and mobile vitals.
Contributor
There was a problem hiding this comment.
Thanks for clarifying! :)
📲 Install BuildsAndroid
|
Distinguish units for the Metrics product from transaction and span measurement units used by mobile vitals. Co-Authored-By: Claude <noreply@anthropic.com>
runningcode
approved these changes
Sep 10, 2026
adinauer
enabled auto-merge (squash)
September 10, 2026 11:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
Document why
MetricsUnitprovides string constants whileMetricsApiaccepts string units instead of reusingMeasurementUnit.💡 Motivation and Context
The distinction is otherwise easy to mistake for accidental duplication.
MeasurementUnitincludes units unsupported by metrics, while accepting strings lets older SDK releases use units introduced later.This records the rationale from #5022.
💚 How did you test it?
Ran
./gradlew spotlessApply apiDump.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
None.
#skip-changelog