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 all commits
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
2 changes: 1 addition & 1 deletion requirements-base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ rfc3986-validator==0.1.1
# [end] jsonschema format validators
sentry-arroyo==0.0.16
sentry-relay==0.8.12
sentry-sdk>=1.4.3,<1.6.0
sentry-sdk>=1.5.12,<1.6.0
snuba-sdk==1.0.0
simplejson==3.17.2
statsd==3.3
Expand Down
5 changes: 5 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 Hub

from sentry import features, search
from sentry.api.bases import OrganizationEventPermission, OrganizationEventsEndpointBase
Expand Down Expand Up @@ -345,6 +346,10 @@ 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 = Hub.current.scope.transaction
if transaction:
transaction.set_measurement("issues.unresolved", len(cursor_result))
Copy link
Contributor

Choose a reason for hiding this comment

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

I could be wrong here since I'm not in issues code very much, but if a user visits the For Review tab directly via url (ie /organizations/sentry/issues/?query=is%3Aunresolved+is%3Afor_review+assigned_or_suggested%3A%5Bme%2C+none%5D&sort=inbox), wouldn't this measurement become inaccurate? It's reporting for issues.unresolved but the actual measurement should be for issues.for_review.

Copy link
Member

Choose a reason for hiding this comment

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

why don't we have a global sentry_sdk.set_measurement for this?

Copy link
Member

Choose a reason for hiding this comment

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

commented above

eventually we'll add top-level api helpers, but since this is experimental this is not exposed all the way yet.


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 Hub

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 @@ -73,6 +78,7 @@ def get(self, request: Request, organization) -> Response:
{"detail": "You do not have the multi project stream feature enabled"}, status=400
)

transaction = Hub.current.scope.transaction
queries = request.GET.getlist("query")
response = {}
for query in queries:
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 transaction and 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
3 changes: 3 additions & 0 deletions src/sentry/utils/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ def _capture_anything(self, method_name, *args, **kwargs):
RedisIntegration(),
ThreadingIntegration(propagate_hub=True),
],
_experiments={
"custom_measurements": True,
},
**sdk_options,
)

Expand Down