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: Extract metrics from sampled transactions [INGEST-331] #1161

Merged
merged 14 commits into from
Jan 12, 2022

Conversation

untitaker
Copy link
Member

@untitaker untitaker commented Dec 20, 2021

Extract metrics from transactions that are affected by sampling rules. Since metrics are extracted from breakdowns, and breakdowns are something commputed in the store normalization, duplicate breakdown computation into the metrics extraction codepath.

We could instead move breakdown extraction upfront, such that the event is mutated before metrics extraction happens, but this way metrics extraction (from dropped transactions) is easier to optimize should that be necessary. Concretely I have the fear that down the road we realize that a) event deserialization is too slow b) making it faster is impossible. If we manage to avoid mutating the event for metrics extraction, it becomes easier to later write a custom Deserialize impl that extracts the data before it is passed to FromValue at all, if we really need to go down that road. There's still some mutation that we'd have to port to metrics extraction though (clock drift processing/finalize_event) if that happens.

We need to be careful about not accidentally writing something different into the event than what we emit for metrics, but we'll just have to see how that plays out. We probably want to ensure that both versions of breakdown computation happen in the same relay instance (i.e. not compute breakdowns for metrics in a customer relay, then write the breakdowns in a processing relay), to avoid version mismatches, but unclear beyond that.

This change does not yet introduce transaction metric extraction to customer relays. So the interaction between dyn. sampling and metrics is only correct if no customer relay is involved. It can still happen that a customer relay drops the transaction without sending metrics, then the processing relay can't do much about it. That's tbd later.

As a side effect, and that's now interesting for @getsentry/visibility, this PR also removes support for ingesting breakdowns from SDKs. There are explicit tests for this functionality, but there's no SDK that actually sends them, and from a quick conversation w alberto it seems that we may not need it anytime soon. Removing this feature simplifies idempotency of breakdown extraction over multiple relays. If it turns out that we need/will need this feature I'd like to know the timeframe so we can appropriately decide whether we should keep it (which means more work now) vs re-add it later (more work in the future).

@untitaker untitaker changed the title [wip] extract metrics before sampling feat: Extract metrics from sampled transactions [INGEST-331] Dec 22, 2021
@untitaker untitaker requested review from a team December 22, 2021 10:29
@untitaker untitaker marked this pull request as ready for review December 22, 2021 10:34
Copy link
Member

@jjbayer jjbayer left a comment

Choose a reason for hiding this comment

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

This looks good to me, do we also need to conditionally disable trace sampling here?

utils::sample_trace(

So basically,

  • if metrics extraction is enabled, defer trace sampling to envelope processor.
  • else, do it in envelope manager as we do now.

Could be a separate PR though.

@untitaker
Copy link
Member Author

@jjbayer goddamnit. i'll try to fix it in the same PR, that was an oversight.

@untitaker
Copy link
Member Author

@jjbayer since we are currently attempting to focus on releasehealth, and in order to not leave this PR hanging around, @jan-auer and I decided that it'd be best to merge this PR in its semi-broken state (assuming we will get buy-in from @getsentry/visibility), and later fix the trace-sampling case.

@dashed
Copy link
Member

dashed commented Jan 11, 2022

@jjbayer since we are currently attempting to focus on releasehealth, and in order to not leave this PR hanging around, @jan-auer and I decided that it'd be best to merge this PR in its semi-broken state (assuming we will get buy-in from @getsentry/visibility), and later fix the trace-sampling case.

@untitaker I'm fine with this behavioural change. But I'll check with the Performance team now that the entire team is 100% back from OOO. If I haven't heard any objections by EOD (Toronto timezone), I'll approve this PR as is.

@silent1mezzo
Copy link

@untitaker overall looks good. I just want to confirm that there would be a way in the future to add breakdowns from SDKs with extra dev work?

@untitaker
Copy link
Member Author

@silent1mezzo It does not become impossible, though at that point we need to define how a span ops breakdown from the SDK is merged with one computed by the server. It depends on those details as to how hard it will be.

@untitaker untitaker enabled auto-merge (squash) January 12, 2022 11:13
@untitaker untitaker merged commit 7ee898d into master Jan 12, 2022
@untitaker untitaker deleted the wip/metrics-before-sampling branch January 12, 2022 11:20
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