Skip to content

feat(sentry-types): Add trace metric protocol envelope support#1022

Open
szokeasaurusrex wants to merge 1 commit intomasterfrom
szokeasaurusrex/metrics-protocol
Open

feat(sentry-types): Add trace metric protocol envelope support#1022
szokeasaurusrex wants to merge 1 commit intomasterfrom
szokeasaurusrex/metrics-protocol

Conversation

@szokeasaurusrex
Copy link
Member

@szokeasaurusrex szokeasaurusrex commented Mar 2, 2026

Add TraceMetric protocol types and trace_metric envelope container serialization/deserialization in sentry-types.

Closes #1008
Closes RUST-159

@linear
Copy link

linear bot commented Mar 2, 2026

@github-actions
Copy link

github-actions bot commented Mar 2, 2026

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

Generated by 🚫 dangerJS against d06efa0

@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/metrics-protocol branch 2 times, most recently from ee23bf8 to 52b0419 Compare March 2, 2026 17:16
@szokeasaurusrex szokeasaurusrex marked this pull request as ready for review March 2, 2026 17:16
@szokeasaurusrex szokeasaurusrex requested a review from lcian as a code owner March 2, 2026 17:16
cursor[bot]

This comment was marked as resolved.

/// The metric name . Uses dot separators for hierarchy.
pub name: String,
/// The numeric value.
pub value: f64,
Copy link
Member

Choose a reason for hiding this comment

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

Is this fine?
It's technically not defined in the spec, but logically you should only be able to send ints for counters while you should be able to send floats for e.g. gauges.
I wonder what happens if you send a counter but serialize the value as 1.0, I guess it depends on how loosely this is defined in Relay/other systems.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like Relay converts all metric values to f64. There's also an example test where a counter is sent with a float value of 1.0.

So, I think it makes sense to stick with f64.

pub unit: Option<String>,
/// Additional key-value attributes.
#[serde(default, skip_serializing_if = "Map::is_empty")]
pub attributes: Map<String, LogAttribute>,
Copy link
Member

Choose a reason for hiding this comment

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

I think we could rename this to Attribute and then alias type LogAttribute = Attribute so that it's not a breaking change if anyone is using it.
wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that could make sense; although, I am slightly concerned that the name Attribute is maybe a bit vague. What if we would want to use Attribute for something else one day? Thoughts?

In any case, let's make this change in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

Well the attributes API we're gonna introduce will take exactly the same types so the concepts would match.

@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/metrics-protocol branch from a5a8201 to d53c02f Compare March 4, 2026 14:13
Add `TraceMetric` protocol types and `trace_metric` envelope container serialization/deserialization in `sentry-types`.

Closes #1008
Closes [RUST-159](https://linear.app/getsentry/issue/RUST-159/add-trace-metric-protocol-models-and-envelope-item-container-support)

Co-authored-by: Joris Bayer <joris.bayer@sentry.io>
Co-authored-by: Lorenzo Cian <17258265+lcian@users.noreply.github.com>
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/metrics-protocol branch from d53c02f to d06efa0 Compare March 4, 2026 14:14
@szokeasaurusrex szokeasaurusrex requested a review from lcian March 4, 2026 14:14
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.

Add trace metric protocol models and envelope item container support

2 participants