Skip to content

docs(metrics): Explain metric unit API design - #6087

Open
adinauer wants to merge 2 commits into
mainfrom
docs/explain-metrics-unit
Open

docs(metrics): Explain metric unit API design#6087
adinauer wants to merge 2 commits into
mainfrom
docs/explain-metrics-unit

Conversation

@adinauer

Copy link
Copy Markdown
Member

📜 Description

Document why MetricsUnit provides string constants while MetricsApi accepts string units instead of reusing MeasurementUnit.

💡 Motivation and Context

The distinction is otherwise easy to mistake for accidental duplication. MeasurementUnit includes 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

  • 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.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

None.

#skip-changelog

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
adinauer marked this pull request as ready for review September 10, 2026 08:12
* <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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So when should we use MetricsUnit and when should we use MeasurementUnit ? And same for customers?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

  • MetricsUnit is for the Metrics product and Sentry.metrics(), scope.metrics() (i.e. IMetricsApi) API.
  • MeasurementUnit is for transaction / span measurement APIs and mobile vitals.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for clarifying! :)

@sentry

sentry Bot commented Sep 10, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.56.0 (1) release

⚙️ sentry-android Build Distribution Settings

Distinguish units for the Metrics product from transaction and span measurement units used by mobile vitals.

Co-Authored-By: Claude <noreply@anthropic.com>
@adinauer
adinauer enabled auto-merge (squash) September 10, 2026 11:06
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.

2 participants