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

ref(am1): Collect span counts for orgs prior to migrating #75485

Merged
merged 4 commits into from
Aug 2, 2024
Merged
Changes from 3 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
21 changes: 20 additions & 1 deletion src/sentry/ingest/consumer/processors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import functools
import logging
from collections.abc import Mapping
from collections.abc import Mapping, MutableMapping
from typing import Any

import orjson
Expand Down Expand Up @@ -187,6 +187,8 @@ def process_event(
event_id=event_id,
project_id=project_id,
)
collect_span_metrics(project, data)
Copy link
Member

Choose a reason for hiding this comment

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

Can we move this into save_event_transaction, and / or wrap it in a try / catch?

This line is part of a try block, but it only DLQs KeyErrors. Any other failure might block the consumer and cause a P0 incident.

# Raise the retriable exception and skip DLQ if anything below this point fails as it may be caused by
# intermittent network issue

Copy link
Member Author

Choose a reason for hiding this comment

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

Wrap in a try/catch is a good idea, sure 👍


elif data.get("type") == "feedback":
if features.has("organizations:user-feedback-ingest", project.organization, actor=None):
save_event_feedback.delay(
Expand Down Expand Up @@ -324,3 +326,20 @@ def process_userreport(message: IngestMessage, project: Project) -> bool:
# If you want to remove this make sure to have triaged all errors in Sentry
logger.exception("userreport.save.crash")
return False


def collect_span_metrics(
project: Project,
data: MutableMapping[str, Any],
):
if not features.has(
"organizations:dynamic-sampling", project.organization
) and not features.has("organizations:am3_tier", project.organization):
amount = (
len(data.get("spans", [])) + 1
) # Segment spans also get added to the total span count.
metrics.incr(
"event.save_event.unsampled.spans.count",
amount=amount,
tags={"organization": project.organization.slug},
)
Loading