Skip to content

feat(metrics): Add before_send_metric callback#1064

Open
szokeasaurusrex wants to merge 1 commit intoszokeasaurusrex/user-attributes-metricsfrom
szokeasaurusrex/before-send-metric
Open

feat(metrics): Add before_send_metric callback#1064
szokeasaurusrex wants to merge 1 commit intoszokeasaurusrex/user-attributes-metricsfrom
szokeasaurusrex/before-send-metric

Conversation

@szokeasaurusrex
Copy link
Copy Markdown
Member

@szokeasaurusrex szokeasaurusrex commented Apr 16, 2026

Run metrics through ClientOptions::before_send_metric after scope/default attribute enrichment and before enqueue so applications can filter or mutate metrics before batching.

Co-authored-by: Joris Bayer joris.bayer@sentry.io

Closes #1025
Closes RUST-170

@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 16, 2026

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 16, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 286f469

@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/before-send-metric branch from a9398ed to cf1dd39 Compare April 17, 2026 08:54
@szokeasaurusrex szokeasaurusrex changed the title feat!(metrics): Add before_send_metric callback feat(metrics): Add before_send_metric callback Apr 17, 2026
@szokeasaurusrex szokeasaurusrex marked this pull request as ready for review April 17, 2026 08:55
@szokeasaurusrex szokeasaurusrex requested a review from lcian as a code owner April 17, 2026 08:55
szokeasaurusrex added a commit that referenced this pull request Apr 17, 2026
Run metrics through `ClientOptions::before_send_metric` after scope/default attribute enrichment and before enqueue so applications can filter or mutate metrics before batching.

Co-authored-by: Joris Bayer <joris.bayer@sentry.io>

 Closes #1025
Closes [RUST-170](https://linear.app/getsentry/issue/RUST-170/add-before-send-metric-callback-processing-in-sentry-core)
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/before-send-metric branch from cf1dd39 to cdad82d Compare April 17, 2026 08:56
Run metrics through `ClientOptions::before_send_metric` after scope/default attribute enrichment and before enqueue so applications can filter or mutate metrics before batching.

Co-authored-by: Joris Bayer <joris.bayer@sentry.io>

 Closes #1025
Closes [RUST-170](https://linear.app/getsentry/issue/RUST-170/add-before-send-metric-callback-processing-in-sentry-core)

assert_eq!(
metric.attributes.get("added_by_callback"),
Some(&LogAttribute(Value::from("yes"))),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did we intend to call this just Attribute (could either be a new type or just a type alias)? I don't remember what was the outcome of that discussion (if any).

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.

Yeah, I think it makes sense to make that change. Likely we should do it as a type alias (rename LogAttribute to Attribute, and make LogAttribute an alias to Attribute). However, I believe we can also do this later, should be a backwards and forwards-compatible change as far as I am aware

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants