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

fix(reprocessing): Add a lot of metrics and explicitly opt tasks into sentry performance product [INGEST-574] #29716

Merged
merged 1 commit into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/sentry/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,11 @@
GroupingLevelNewIssuesEndpoint.as_view(),
),
url(r"^(?P<issue_id>[^\/]+)/hashes/split/$", GroupHashesSplitEndpoint.as_view()),
url(r"^(?P<issue_id>[^\/]+)/reprocessing/$", GroupReprocessingEndpoint.as_view()),
url(
r"^(?P<issue_id>[^\/]+)/reprocessing/$",
GroupReprocessingEndpoint.as_view(),
name="sentry-api-0-issues-reprocessing",
),
url(r"^(?P<issue_id>[^\/]+)/stats/$", GroupStatsEndpoint.as_view()),
url(r"^(?P<issue_id>[^\/]+)/tags/$", GroupTagsEndpoint.as_view()),
url(r"^(?P<issue_id>[^\/]+)/tags/(?P<key>[^/]+)/$", GroupTagKeyDetailsEndpoint.as_view()),
Expand Down
3 changes: 3 additions & 0 deletions src/sentry/conf/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,9 @@ def create_partitioned_queues(name):
# sample rate for post_process_group task
SENTRY_POST_PROCESS_GROUP_APM_SAMPLING = 0

# sample rate for all reprocessing tasks (except for the per-event ones)
SENTRY_REPROCESSING_APM_SAMPLING = 0

# ----
# end APM config
# ----
Expand Down
2 changes: 2 additions & 0 deletions src/sentry/reprocessing2.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,8 @@ def start_group_reprocessing(
referrer="reprocessing2.start_group_reprocessing",
)["data"][0]["times_seen"]

sentry_sdk.set_extra("event_count", event_count)
Copy link
Member

Choose a reason for hiding this comment

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

Is this set_extra limited to the scope of the @instrumented_task? Same question for set_tag below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes


if max_events is not None:
event_count = min(max_events, event_count)

Expand Down
13 changes: 13 additions & 0 deletions src/sentry/tasks/reprocessing2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from sentry import eventstore, eventstream, nodestore
from sentry.eventstore.models import Event
from sentry.tasks.base import instrumented_task, retry
from sentry.utils import metrics
from sentry.utils.query import celery_run_batch_query


Expand All @@ -27,6 +28,8 @@ def reprocess_group(
acting_user_id=None,
):
sentry_sdk.set_tag("project", project_id)
sentry_sdk.set_tag("group_id", group_id)

from sentry.reprocessing2 import (
CannotReprocess,
buffered_handle_remaining_events,
Expand All @@ -35,9 +38,13 @@ def reprocess_group(
start_group_reprocessing,
)

sentry_sdk.set_tag("is_start", "false")

if start_time is None:
assert new_group_id is None
start_time = time.time()
metrics.incr("events.reprocessing.start_group_reprocessing", sample_rate=1.0)
sentry_sdk.set_tag("is_start", "true")
new_group_id = start_group_reprocessing(
project_id,
group_id,
Expand Down Expand Up @@ -154,6 +161,12 @@ def handle_remaining_events(
event_ids_redis_key
)

metrics.timing(
"events.reprocessing.handle_remaining_events.batch_size",
len(event_ids),
sample_rate=1.0,
)

assert remaining_events in ("delete", "keep")

if remaining_events == "delete":
Expand Down
5 changes: 5 additions & 0 deletions src/sentry/utils/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
"sentry-logout": 0.1,
"sentry-register": settings.SAMPLED_DEFAULT_RATE,
"sentry-2fa-dialog": settings.SAMPLED_DEFAULT_RATE,
# reprocessing
"sentry-api-0-issues-reprocessing": settings.SENTRY_REPROCESSING_APM_SAMPLING,
}
if settings.ADDITIONAL_SAMPLED_URLS:
SAMPLED_URL_NAMES.update(settings.ADDITIONAL_SAMPLED_URLS)
Expand All @@ -84,6 +86,9 @@
"sentry.tasks.app_store_connect.refresh_all_builds": settings.SENTRY_APPCONNECT_APM_SAMPLING,
"sentry.tasks.process_suspect_commits": settings.SENTRY_SUSPECT_COMMITS_APM_SAMPLING,
"sentry.tasks.post_process.post_process_group": settings.SENTRY_POST_PROCESS_GROUP_APM_SAMPLING,
"sentry.tasks.reprocessing2.handle_remaining_events": settings.SENTRY_REPROCESSING_APM_SAMPLING,
"sentry.tasks.reprocessing2.reprocess_group": settings.SENTRY_REPROCESSING_APM_SAMPLING,
"sentry.tasks.reprocessing2.finish_reprocessing": settings.SENTRY_REPROCESSING_APM_SAMPLING,
}


Expand Down