feat(metrics): Basic metrics capturing functionality in sentry-core#1073
feat(metrics): Basic metrics capturing functionality in sentry-core#1073szokeasaurusrex wants to merge 1 commit intoszokeasaurusrex/metrics-protocolfrom
Conversation
|
532ad35 to
d47f8a2
Compare
fda826a to
1b0c9be
Compare
d47f8a2 to
88d565c
Compare
fb6c66b to
b887824
Compare
bd6780b to
1932f45
Compare
1861bc0 to
aadec60
Compare
…1073) Basic metrics capture functionality. Follow-up PR will implement the rest. Stacked on #1022 Co-authored-by: Joris Bayer <joris.bayer@sentry.io> Closes #1023 Closes [RUST-168](https://linear.app/getsentry/issue/RUST-168/implement-trace-metric-capture-and-batching-in-sentry-core) Closes #1058 Closes [RUST-186](https://linear.app/getsentry/issue/RUST-186/add-trace-metric-tracing-association-in-sentry-core)
aadec60 to
06aeb9d
Compare
…1073) Basic metrics capture functionality. Follow-up PR will implement the rest. Stacked on #1022 Co-authored-by: Joris Bayer <joris.bayer@sentry.io> Closes #1023 Closes [RUST-168](https://linear.app/getsentry/issue/RUST-168/implement-trace-metric-capture-and-batching-in-sentry-core) Closes #1058 Closes [RUST-186](https://linear.app/getsentry/issue/RUST-186/add-trace-metric-tracing-association-in-sentry-core)
06aeb9d to
cf4fe98
Compare
…1073) Basic metrics capture functionality. Follow-up PR will implement the rest. Stacked on #1022 Co-authored-by: Joris Bayer <joris.bayer@sentry.io> Closes #1023 Closes [RUST-168](https://linear.app/getsentry/issue/RUST-168/implement-trace-metric-capture-and-batching-in-sentry-core) Closes #1058 Closes [RUST-186](https://linear.app/getsentry/issue/RUST-186/add-trace-metric-tracing-association-in-sentry-core)
cf4fe98 to
f27b842
Compare
…1073) Basic metrics capture functionality. Follow-up PR will implement the rest. Stacked on #1022 Co-authored-by: Joris Bayer <joris.bayer@sentry.io> Closes #1023 Closes [RUST-168](https://linear.app/getsentry/issue/RUST-168/implement-trace-metric-capture-and-batching-in-sentry-core) Closes #1058 Closes [RUST-186](https://linear.app/getsentry/issue/RUST-186/add-trace-metric-tracing-association-in-sentry-core)
f27b842 to
93692bd
Compare
giortzisg
left a comment
There was a problem hiding this comment.
overall looks good, just left a comment for attribute ordering and some minor nits.
| pub struct CounterMetric { | ||
| inner: MetricInner, | ||
| } | ||
|
|
||
| /// A gauge metric, created with [`gauge`]. | ||
| #[must_use = "metrics must be captured via `.capture()` to be sent to Sentry"] | ||
| pub struct GaugeMetric { | ||
| inner: UnitMetricInner, | ||
| } | ||
|
|
||
| /// A distribution metric, created with [`distribution`]. | ||
| #[must_use = "metrics must be captured via `.capture()` to be sent to Sentry"] | ||
| pub struct DistributionMetric { | ||
| inner: UnitMetricInner, | ||
| } |
There was a problem hiding this comment.
The ability to add a unit is only implemented for gauge and distribution metrics, as units are only applicable to those metric types per the spec.
Using an enum would not allow us to have .unit only exist for gauge and distribution, but not counter metrics. So, while this design is a bit more complex, we can actually encode the semantics via the API.
…1073) Basic metrics capture functionality. Follow-up PR will implement the rest. Stacked on #1022 Co-authored-by: Joris Bayer <joris.bayer@sentry.io> Closes #1023 Closes [RUST-168](https://linear.app/getsentry/issue/RUST-168/implement-trace-metric-capture-and-batching-in-sentry-core) Closes #1058 Closes [RUST-186](https://linear.app/getsentry/issue/RUST-186/add-trace-metric-tracing-association-in-sentry-core)
93692bd to
cd20001
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cd20001. Configure here.
…1073) Basic metrics capture functionality. Follow-up PR will implement the rest. Stacked on #1022 Co-authored-by: Joris Bayer <joris.bayer@sentry.io> Closes #1023 Closes [RUST-168](https://linear.app/getsentry/issue/RUST-168/implement-trace-metric-capture-and-batching-in-sentry-core) Closes #1058 Closes [RUST-186](https://linear.app/getsentry/issue/RUST-186/add-trace-metric-tracing-association-in-sentry-core)
cd20001 to
d383c6c
Compare
…1073) Basic metrics capture functionality. Follow-up PR will implement the rest. Stacked on #1022 Co-authored-by: Joris Bayer <joris.bayer@sentry.io> Closes #1023 Closes [RUST-168](https://linear.app/getsentry/issue/RUST-168/implement-trace-metric-capture-and-batching-in-sentry-core) Closes #1058 Closes [RUST-186](https://linear.app/getsentry/issue/RUST-186/add-trace-metric-tracing-association-in-sentry-core)
d383c6c to
07acfeb
Compare
Remove the blanket `#![allow(unused)]` in `sentry-core/src/hub.rs`. This will allow the linter to find problems [like this](#1073 (comment)) and many more, rather than needing to rely on the clanker for such things. Instead, we now have a macro that adds a `let _ = ...arguments...` when the `client` feature is enabled. This solves the stated purpose of having the `allow(unused)` in the first place, but where more narrowly. The clanker also cleaned up some truly unused things that were suppressed before. <details> <summary>What the clanker wrote</summary> <!-- CURSOR_AGENT_PR_BODY_BEGIN --> ### Description Removes the blanket `#![allow(unused)]` from `sentry-core/src/hub.rs`. Instead of repeating a long `#[cfg_attr(not(feature = "client"), expect(unused, ...))]` annotation across many parameters, this change uses a small documented local `use_without_client!` helper macro that only touches those values in `not(feature = "client")` builds. That keeps the handling narrow to the specific methods and arguments that need it, while avoiding duplicated attributes in the signatures. Also cleans up truly unused imports, removes an unnecessary `mut` in the release-health session setup path, and keeps the file rustfmt-clean for CI. Validated with: - `cargo +1.88.0 fmt --all --check` - `cargo +1.88.0 clippy -p sentry-core --no-default-features -- -D warnings` - `cargo +1.88.0 clippy -p sentry-core --no-default-features --features client -- -D warnings` - `cargo +1.88.0 clippy -p sentry-core --all-features -- -D warnings` - `cargo +1.88.0 clippy -p sentry-core --no-default-features --features release-health -- -D warnings` - `cargo +1.88.0 clippy -p sentry-core --no-default-features --features logs -- -D warnings` Note: a full local workspace `cargo clippy --all-features --workspace --tests --examples --locked` is blocked in this environment by missing system OpenSSL development libraries, which is unrelated to this `hub.rs` change. #### Issues - N/A #### Reminders - GH Issue ID / Linear ID: N/A - CHANGELOG.md: not updated (internal lint cleanup) - PR title uses conventional commit style - Useful links for external contributors: [Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord community](https://discord.gg/sentry) <!-- CURSOR_AGENT_PR_BODY_END --> </details> <div><a href="https://cursor.com/agents/bc-0342af16-4799-43c3-8028-50dc657541e4"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-0342af16-4799-43c3-8028-50dc657541e4"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Daniel Szoke <szokeasaurusrex@users.noreply.github.com>
…1073) Basic metrics capture functionality. Follow-up PR will implement the rest. Stacked on #1022 Co-authored-by: Joris Bayer <joris.bayer@sentry.io> Closes #1023 Closes [RUST-168](https://linear.app/getsentry/issue/RUST-168/implement-trace-metric-capture-and-batching-in-sentry-core) Closes #1058 Closes [RUST-186](https://linear.app/getsentry/issue/RUST-186/add-trace-metric-tracing-association-in-sentry-core)
07acfeb to
207d6fc
Compare
…1073) Basic metrics capture functionality. Follow-up PR will implement the rest. Stacked on #1022 Co-authored-by: Joris Bayer <joris.bayer@sentry.io> Closes #1023 Closes [RUST-168](https://linear.app/getsentry/issue/RUST-168/implement-trace-metric-capture-and-batching-in-sentry-core) Closes #1058 Closes [RUST-186](https://linear.app/getsentry/issue/RUST-186/add-trace-metric-tracing-association-in-sentry-core)
207d6fc to
0c98e2f
Compare

Basic metrics capture functionality. Follow-up PR will implement the rest.
This PR implements public APIs for capturing metrics, plus batching when sending them.
Stacked on #1022
Co-authored-by: Joris Bayer joris.bayer@sentry.io
Closes #1073
Closes RUST-193
Closes #1023
Closes RUST-168
Closes #1058
Closes RUST-186