Skip to content

docs(develop): Loosen metrics SDK spec for modules#17389

Closed
szokeasaurusrex wants to merge 2 commits intomasterfrom
szokeasaurusrex-patch-1
Closed

docs(develop): Loosen metrics SDK spec for modules#17389
szokeasaurusrex wants to merge 2 commits intomasterfrom
szokeasaurusrex-patch-1

Conversation

@szokeasaurusrex
Copy link
Copy Markdown
Member

@szokeasaurusrex szokeasaurusrex commented Apr 20, 2026

The "metrics module" section in the "metrics" develop spec is too restrictive.

In Rust, for example, we can implement a more ergonomic API by using macros instead of methods. Due to language restrictions, it is not possible to define macros in a module, only in the top-level of the crate, so we use metric_count!, metric_guage! and metric_distribution! instead. This API aligns with what we already do for logs in the Rust SDK.

Therefore, I propose loosening the requirements. The only "MUST"-level requirement in my proposal would be to expose this functionality; the precise API is lowered to "SHOULD"-level requirements to allow SDKs to deviate where this would be beneficial.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
develop-docs Ready Ready Preview, Comment Apr 20, 2026 9:42am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
sentry-docs Ignored Ignored Preview Apr 20, 2026 9:42am

Request Review

@github-actions github-actions Bot added the sdk-develop-docs PRs touching develop-docs/sdk label Apr 20, 2026
Updated the terminology for function naming conventions in the metrics documentation.
@szokeasaurusrex szokeasaurusrex changed the title docs(develop): Loosen metrics SDK spec docs(develop): Loosen metrics SDK spec for modules Apr 20, 2026
Copy link
Copy Markdown
Member

@cleptric cleptric left a comment

Choose a reason for hiding this comment

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

We still should expose metrics_gauge etc. functions, you can add additional macros as you see fit. Only exposing macros on a hot path won't scale fwiw, so these functions are still mandatory.
I'm also confused with what you stated about logs in Rust, are our docs wrong? https://docs.sentry.io/platforms/rust/logs/#best-practices

@szokeasaurusrex szokeasaurusrex removed the request for review from stephanie-anderson April 20, 2026 13:14
@szokeasaurusrex
Copy link
Copy Markdown
Member Author

szokeasaurusrex commented Apr 20, 2026

@cleptric Sounds good, I will also add the functions to the Rust SDK.

Regarding the following:

I'm also confused with what you stated about logs in Rust, are our docs wrong?

Yes, the docs are very wrong. None of the examples in that section compile, and I have opened #17393 to delete the section for now. More context on that PR.

<SpecSection id="metrics-module" status="stable" since="2.0.0">

### Metrics Module
### Metrics Capturing Functionality
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.

Suggested change
### Metrics Capturing Functionality
### Metrics Capture Functionality

SDKs **MUST** expose metrics methods in a `metrics` module or namespace. At minimum, the SDK **MUST** implement the following methods:
SDKs **MUST** expose functionality for capturing `count`, `gauge`, and `distribution` metrics.

Metrics-capturing functionality **SHOULD** be exposed as functions (or another suitable language construct) in a `metrics` module or namespace. If exposing the functionality in a module or namespace is infeasible in a particular SDK's language, the function names **SHOULD** be prefixed with the word `metric`.
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.

Suggested change
Metrics-capturing functionality **SHOULD** be exposed as functions (or another suitable language construct) in a `metrics` module or namespace. If exposing the functionality in a module or namespace is infeasible in a particular SDK's language, the function names **SHOULD** be prefixed with the word `metric`.
Metrics capture functionality **SHOULD** be exposed as functions (or another suitable language construct) in a `metrics` module or namespace. If exposing the functionality in a module or namespace is infeasible in a particular SDK's language, the function names **SHOULD** be prefixed with the word `metric`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sdk-develop-docs PRs touching develop-docs/sdk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants