Skip to content

fix(test): Use trusted Relay in trace metric test#5917

Open
loewenheim wants to merge 2 commits intomasterfrom
sebastian/fix-trace-metric-test
Open

fix(test): Use trusted Relay in trace metric test#5917
loewenheim wants to merge 2 commits intomasterfrom
sebastian/fix-trace-metric-test

Conversation

@loewenheim
Copy link
Copy Markdown
Contributor

@loewenheim loewenheim commented Apr 30, 2026

The size of a trace metric, which is relevant for billing, is supposed to be computed by the first trusted Relay in the chain and then not recomputed by subsequent Relays. This ensures that we only bill on data sent to us by the customer, not on normalizations we apply.

This PR parametrizes the test_trace_metric_extraction test with different scenarios for external Relays to check that this works correctly for both trusted and untrusted Relays.

The size of a trace metric, which is relevant for billing, is supposed
to be computed by the first trusted Relay in the chain and then not
recomputed by subsequent Relays. This ensures that we only bill on data
sent to us by the customer, not on normalizations we apply.

Not using a trusted Relay in the test makes us recompute the size after
normalization.
@loewenheim loewenheim requested a review from a team as a code owner April 30, 2026 12:20
@loewenheim loewenheim added bug Something isn't working skip-changelog labels Apr 30, 2026
Copy link
Copy Markdown
Member

@Dav1dde Dav1dde left a comment

Choose a reason for hiding this comment

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

I think it makes sense to look at the test_ourlog_extraction_with_sentry_logs and port over all the different modes.

@pytest.mark.parametrize(
    "external_mode,expected_byte_size_1,expected_byte_size_2",
    [
        # The values here are billing relevant metrics, do not arbitrarily change it,
        # these values are supposed to be static and purely based on data received,
        # independent of any normalization.
        (None, 18, 359),
        # Same applies as above, a proxy Relay does not need to run normalization.
        ("proxy", 18, 359),
        # If an external Relay/Client makes modifications, sizes can change,
        # this is fuzzy due to slight changes in sizes due to added timestamps
        # and may need to be adjusted when changing normalization.
        ("managed", 128, 459),
    ],
)

Then again this is just a straight up improvement ✅

@loewenheim
Copy link
Copy Markdown
Contributor Author

I think it makes sense to look at the test_ourlog_extraction_with_sentry_logs and port over all the different modes.

That's actually a good idea, I wasn't thinking that far.

@loewenheim loewenheim enabled auto-merge April 30, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working skip-changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants