Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(transactions): Extract computed measurements [INGEST-1530] #1373

Merged
merged 7 commits into from
Aug 3, 2022

Conversation

jjbayer
Copy link
Member

@jjbayer jjbayer commented Aug 2, 2022

Extract the following derived mobile measurements, and write them back into the transaction:

frames_slow_rate := measurements.frames_slow / measurements.frames_total
frames_frozen_rate := measurements.frames_frozen / measurements.frames_total
stall_percentage := measurements.stall_total_time / transaction.duration

These new measurements will be available in both the metrics and the transactions dataset.

The addition to the measurement allowlist is done in getsentry/sentry#37330.

.and_then(Annotated::value)
{
if stall_total_time.unit.value()
== Some(&MetricUnit::Duration(DurationUnit::MilliSecond))
Copy link
Member Author

Choose a reason for hiding this comment

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

This strict check means that we do not set stall_percentage if stall_total_time has unit None. Ideally, get_measurement_unit would run as part of store normalization such that we don't have to think about this special case.

Copy link
Member

@jan-auer jan-auer Aug 2, 2022

Choose a reason for hiding this comment

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

Please ensure that this is considered in #1366. It's still very common for SDKs to skip the unit and it's also not required.

What would be the downside of omitting this check?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the SDK sends seconds instead of milliseconds for some reason, we divide seconds by milliseconds. But I'll relax the condition to accept None as well.

Comment on lines 128 to 130
100.0 * (stall_total_time / transaction_duration_ms),
),
unit: Annotated::new(MetricUnit::Fraction(FractionUnit::Percent)),
Copy link
Member Author

Choose a reason for hiding this comment

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

@wmak I multiply by 100 and set the unit Percent here, because that is what the name percentage seems to imply. But looking at https://github.com/getsentry/sentry/blob/3b3cb01fd16e9ccce104a077efa29a89d8253891/src/sentry/search/events/datasets/discover.py#L1222-L1225, the product actually expects a ratio between 0 and 1?

    def _resolve_measurements_stall_percentage(self, _: str) -> SelectType:
        return self._resolve_aliased_division(
            "measurements.stall_total_time", "transaction.duration", MEASUREMENTS_STALL_PERCENTAGE
        )

Copy link
Member

@jan-auer jan-auer Aug 2, 2022

Choose a reason for hiding this comment

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

The definition in search fields makes this a ratio like all others without a multiplication by 100. The product type of "percentage" is actually 0-1. See: https://github.com/getsentry/sentry/blob/8b13ba0e01744d88632d6b8cff185f5644b40c0a/src/sentry/search/events/fields.py#L414-L426

PseudoField(
    MEASUREMENTS_STALL_PERCENTAGE,
    MEASUREMENTS_STALL_PERCENTAGE,
    expression=[
        "if",
        [
            ["greater", ["transaction.duration", 0]],
            ["divide", ["measurements.stall_total_time", "transaction.duration"]],
            None,
        ],
    ],
    result_type="percentage",
),

Copy link
Member Author

Choose a reason for hiding this comment

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

ACK, will change the unit.

Copy link
Member

Choose a reason for hiding this comment

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

+1 Jan is correct here, but there's no strong reason for 0-1 or 0-100 it was just an arbitrary decision. So if there was a good reason to we could likely update to 0-100.

Copy link
Member Author

Choose a reason for hiding this comment

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

@wmak thanks, let's keep it 0-1.

@jjbayer jjbayer marked this pull request as ready for review August 2, 2022 08:03
@jjbayer jjbayer requested review from a team and wmak August 2, 2022 08:03
@jjbayer jjbayer requested a review from jan-auer August 2, 2022 13:42
jjbayer added a commit to getsentry/sentry that referenced this pull request Aug 3, 2022
The following measurements were removed from metrics extraction under
the assumption that they could be computed on the fly:

frames_slow_rate := measurements.frames_slow / measurements.frames_total
frames_frozen_rate := measurements.frames_frozen / measurements.frames_total
stall_percentage := measurements.stall_total_time / transaction.duration

They cannot, because for example p75(a/b) is not the same as p75(a)/p75(b).

This reverts #33725.

Relay part implemented here: getsentry/relay#1373
@jjbayer jjbayer merged commit 3832874 into master Aug 3, 2022
@jjbayer jjbayer deleted the feat/metrics-computed-measurements branch August 3, 2022 07:44
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.

4 participants