Skip to content

Commit

Permalink
temporarily track snuba user count queries
Browse files Browse the repository at this point in the history
  • Loading branch information
cathteng committed Aug 12, 2024
1 parent 47a1134 commit f205aaf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/sentry/integrations/slack/message_builder/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
from sentry.types.actor import Actor
from sentry.types.group import SUBSTATUS_TO_STR
from sentry.users.services.user.model import RpcUser
from sentry.utils import metrics

STATUSES = {"resolved": "resolved", "ignored": "ignored", "unresolved": "re-opened"}
SUPPORTED_COMMIT_PROVIDERS = (
Expand All @@ -80,9 +81,7 @@
# pull things out into their own functions
SUPPORTED_CONTEXT_DATA = {
"Events": lambda group: get_group_global_count(group),
"Users Affected": lambda group: group.count_users_seen(
referrer=Referrer.TAGSTORE_GET_GROUPS_USER_COUNTS_SLACK_ISSUE_NOTIFICATION.value
),
"Users Affected": lambda group: get_group_users_count(group),
"State": lambda group: SUBSTATUS_TO_STR.get(group.substatus, "").replace("_", " ").title(),
"First Seen": lambda group: time_since(group.first_seen),
"Approx. Start Time": lambda group: datetime.fromtimestamp(
Expand All @@ -101,6 +100,13 @@
logger = logging.getLogger(__name__)


def get_group_users_count(group: Group) -> int:
metrics.incr("slack.get_group_users_count", tags={"group": group.id}, sample_rate=1.0)
return group.count_users_seen(
referrer=Referrer.TAGSTORE_GET_GROUPS_USER_COUNTS_SLACK_ISSUE_NOTIFICATION.value
)


def build_assigned_text(identity: RpcIdentity, assignee: str) -> str | None:
actor = Actor.from_identifier(assignee)

Expand Down

0 comments on commit f205aaf

Please sign in to comment.