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(spans): Add a new recombiner consumer #66804

Merged
merged 18 commits into from Mar 21, 2024

Conversation

shruthilayaj
Copy link
Member

@shruthilayaj shruthilayaj commented Mar 12, 2024

We're moving away from celery tasks + rabbit and instead
want a second consumer that processes segments. This
PR adds the new topic and consumer and refactors code
away from tasks.

This code doesn't run in prod yet.

In a follow up, the process-spans consumer will fetch
segments that are ready to be processed and push them
to the buffered-segments topic

@shruthilayaj shruthilayaj changed the title feat(spans): Add a new recombiner consumer @shruthilayaj feat(spans): Add a new recombiner consumer Mar 12, 2024
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 12, 2024
Copy link

codecov bot commented Mar 12, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 84.34%. Comparing base (95e34c4) to head (0918a0b).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #66804      +/-   ##
==========================================
+ Coverage   79.36%   84.34%   +4.97%     
==========================================
  Files        6364     5315    -1049     
  Lines      281973   237410   -44563     
  Branches    48521    41061    -7460     
==========================================
- Hits       223788   200241   -23547     
+ Misses      57822    36951   -20871     
+ Partials      363      218     -145     
Files Coverage Δ
src/sentry/conf/server.py 89.63% <ø> (ø)
src/sentry/conf/types/kafka_definition.py 100.00% <100.00%> (ø)
src/sentry/consumers/__init__.py 76.74% <ø> (ø)
...ans/consumers/detect_performance_issues/message.py 99.07% <100.00%> (ø)
src/sentry/spans/consumers/process/factory.py 91.66% <100.00%> (-0.65%) ⬇️
src/sentry/utils/sdk.py 81.37% <ø> (ø)
...ans/consumers/detect_performance_issues/factory.py 84.37% <84.37%> (ø)

... and 3109 files with indirect coverage changes

@shruthilayaj shruthilayaj marked this pull request as ready for review March 12, 2024 21:07
@shruthilayaj shruthilayaj requested review from a team as code owners March 12, 2024 21:07
@shruthilayaj shruthilayaj requested review from a team and phacops March 12, 2024 21:07
@shruthilayaj
Copy link
Member Author

Ah I need to define a schema for the new topic

@shruthilayaj shruthilayaj marked this pull request as draft March 13, 2024 14:39
@shruthilayaj
Copy link
Member Author

Blocked by getsentry/sentry-kafka-schemas#237

@shruthilayaj shruthilayaj marked this pull request as ready for review March 14, 2024 13:39
@@ -45,6 +45,7 @@ class Topic(Enum):
GROUP_ATTRIBUTES = "group-attributes"
SHARED_RESOURCES_USAGE = "shared-resources-usage"
SNUBA_SPANS = "snuba-spans"
BUFFERED_SEGMENT = "buffered-segment"
Copy link
Member

Choose a reason for hiding this comment

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

Does this topic actually exist in prod?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it does not. None of these consumers/topics/redis existing in prod yet

Copy link
Member

Choose a reason for hiding this comment

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

Is there a concern of deploying this when the infrastructure doesn't exist?

Copy link
Member Author

Choose a reason for hiding this comment

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

The consumer code is for sure okay to deploy without the infra in place (since ops actually needs to manually deploy the consumers), and the consumers producing to and reading from this topic aren't actually running in production, so I assumed it would be fine. @phacops do you know if that's the case?

Copy link
Member Author

Choose a reason for hiding this comment

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

@evanh I'm going to make an ops ticket to get this topic configured and make sure that goes through before I merge this PR just to be safe

Copy link
Member Author

Choose a reason for hiding this comment

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

Ops ticket

Copy link
Member Author

Choose a reason for hiding this comment

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

The preference is to merge all the code first and then deploy infra to prod in the right order (details in the ticket), so I'm going to merge this PR cc: @evanh

try:
process_segment(segments)
except Exception as e:
if random.random() < 0.05:
Copy link
Member

Choose a reason for hiding this comment

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

Why sample this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to log exception instead - had just copied over an old pattern

Copy link
Member

@antonpirker antonpirker left a comment

Choose a reason for hiding this comment

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

Just left one question.

Comment on lines 40 to 41
"/sentry/spans/consumers/process/factory.py",
"/sentry/spans/consumers/recombine/factory.py",
Copy link
Member

Choose a reason for hiding this comment

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

Why do those have a / prefixed in contrast to the others?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh good catch!

"profile_id": "7ce060d7ea62432b8355bc9e612676e4",
"project_id": 1,
"received": 1706734067.029479,
"description": "OrganizationNPlusOne",
Copy link
Member Author

Choose a reason for hiding this comment

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

Just plopped in a different span here, sorry!

@shruthilayaj shruthilayaj requested a review from evanh March 21, 2024 12:19
@shruthilayaj shruthilayaj merged commit ff45ba4 into master Mar 21, 2024
49 checks passed
@shruthilayaj shruthilayaj deleted the shruthi/feat/add-recombiner-consumer branch March 21, 2024 13:39
@github-actions github-actions bot locked and limited conversation to collaborators Apr 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants