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

refs(metrics) Count/measure the number of issues on the issue page. #35422

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/sentry/api/endpoints/organization_group_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from rest_framework.exceptions import ParseError, PermissionDenied
from rest_framework.request import Request
from rest_framework.response import Response
from sentry_sdk import start_transaction

from sentry import features, search
from sentry.api.bases import OrganizationEventPermission, OrganizationEventsEndpointBase
Expand Down Expand Up @@ -345,6 +346,9 @@ def get(self, request: Request, organization) -> Response:
self.add_cursor_headers(request, response, cursor_result)

# TODO(jess): add metrics that are similar to project endpoint here
transaction = start_transaction(name="measuring issues")
transaction.set_measurement("issues.unresolved", len(cursor_result))

return response

@track_slo_response("workflow")
Expand Down
14 changes: 12 additions & 2 deletions src/sentry/api/endpoints/organization_issues_count.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from rest_framework.exceptions import ParseError
from rest_framework.request import Request
from rest_framework.response import Response
from sentry_sdk import start_transaction

from sentry import features, search
from sentry.api.bases import OrganizationEventsEndpointBase
Expand All @@ -11,9 +12,13 @@
from sentry.types.ratelimit import RateLimit, RateLimitCategory

ERR_INVALID_STATS_PERIOD = "Invalid stats_period. Valid choices are '', '24h', and '14d'"


ISSUES_COUNT_MAX_HITS_LIMIT = 100
QUERY_NAMES = {
"is:unresolved is:for_review assigned_or_suggested:[me, none]": "for_review",
"is:unresolved": "unresolved",
"is:ignored": "ignored",
"is:reprocessing": "reprocessing",
}


class OrganizationIssuesCountEndpoint(OrganizationEventsEndpointBase):
Expand Down Expand Up @@ -75,6 +80,7 @@ def get(self, request: Request, organization) -> Response:

queries = request.GET.getlist("query")
response = {}
transaction = start_transaction(name="measuring issues")
for query in queries:
try:
count = self._count(
Expand All @@ -86,6 +92,10 @@ def get(self, request: Request, organization) -> Response:
{"count_hits": True, "date_to": end, "date_from": start},
)
response[query] = count
query_name = QUERY_NAMES.get(query, None)
if query_name and count:
transaction.set_measurement(f"issues.{query_name}", count)

except (ValidationError, discover.InvalidSearchQuery) as exc:
return Response({"detail": str(exc)}, status=400)

Expand Down