Skip to content

feat(profiles): Add support for continuous profiling#3270

Merged
phacops merged 40 commits intomasterfrom
pierre/continuous-profiling
Mar 27, 2024
Merged

feat(profiles): Add support for continuous profiling#3270
phacops merged 40 commits intomasterfrom
pierre/continuous-profiling

Conversation

@phacops
Copy link
Copy Markdown
Contributor

@phacops phacops commented Mar 14, 2024

This aims to add support for continuous profiling.

If the continuous profiling option is enabled, the SDK will start a profiler at the same time it starts. The profiler will generate a random profiler_id and start profiling in chunks of a fixed duration (likely 10s) and send each chunk to Relay.

The chunks will be handled as a separate ItemType and have a separate DataCategory. The schema of the payload is our Sample format V2, resembling V1 but incompatible with it. Changes are:

  • sample timestamps are now in milliseconds, represented as a f64 instead of a String and renamed timestamp_ms
  • OS/runtime/device metadata are removed
  • queue metadata is merged with thread metadata
  • new profiler_id field representing a profiling session
  • no more transaction metadata

Each chunk will then be sent through the same topic to our consumers for further processing and storage. Accepted outcomes based on the duration of each chunk in milliseconds will be emitted there.

@phacops phacops requested review from Dav1dde and jjbayer March 14, 2024 18:20
@phacops phacops self-assigned this Mar 14, 2024
@phacops phacops requested a review from a team as a code owner March 14, 2024 18:20
Copy link
Copy Markdown
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.

Looks good overall! Could you please add an integration test to test_store.py to make sure the entire pipeline works as expected?

@phacops phacops requested review from Zylphrex and jjbayer March 18, 2024 23:51
item.set_payload(ContentType::Json, payload);
ItemAction::Keep
} else {
ItemAction::Drop(Outcome::Invalid(DiscardReason::Profiling(
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.

We should update Item::quantity() to avoid creating outcomes that default to quantity=1:

pub fn quantity(&self) -> usize {
match self.ty() {
ItemType::Attachment => self.len().max(1),
_ => 1,
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't know if we have a good quantity to set here. Since quantity is now the duration of a profile, it means we need to first parse and process the profile properly, and since Relay won't emit Accepted outcomes for profile chunks and only invalid ones, how useful it is to try to process the profile to determine the appropriate duration we failed to ingest?

It will make some charts look a bit weird since it won't be the same unit for valid and invalid profile chunks. I could still try to get a duration but we would still have cases where the profile chunk is malformed or sending bogus data and we can't determine the duration of the profile chunk.

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.

After a short discussion with @Dav1dde, I believe the only correct solution is having two different outcomes: one for the number of profile chunks and one for the duration. Not necessarily a blocker for this PR, but I think it's a change we should make.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Only a quick check without checking logic.

@phacops phacops force-pushed the pierre/continuous-profiling branch from aa31f30 to e084069 Compare March 19, 2024 15:11
@phacops phacops requested review from Dav1dde and jjbayer March 20, 2024 13:04
Copy link
Copy Markdown
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.

I would still add an integration test before we merge this, apart from that this looks good to me.

item.set_payload(ContentType::Json, payload);
ItemAction::Keep
} else {
ItemAction::Drop(Outcome::Invalid(DiscardReason::Profiling(
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.

After a short discussion with @Dav1dde, I believe the only correct solution is having two different outcomes: one for the number of profile chunks and one for the duration. Not necessarily a blocker for this PR, but I think it's a change we should make.

@phacops phacops requested a review from jjbayer March 21, 2024 20:23
@phacops phacops enabled auto-merge (squash) March 26, 2024 19:09
@phacops phacops merged commit f59f6a1 into master Mar 27, 2024
@phacops phacops deleted the pierre/continuous-profiling branch March 27, 2024 06:25
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