Skip to content

Commit

Permalink
Merge branch 'master' into wmak/chore/add-in-filter-test
Browse files Browse the repository at this point in the history
  • Loading branch information
wmak authored Dec 12, 2024
2 parents 458ef13 + e7e0d1a commit 5b4c4ea
Show file tree
Hide file tree
Showing 152 changed files with 2,310 additions and 2,374 deletions.
15 changes: 12 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,21 @@ tests/sentry/api/endpoints/test_organization_dashboard_widget_details.py @ge


## DevToolbar
/src/sentry/templates/sentry/toolbar/ @getsentry/replay
/src/sentry/toolbar/ @getsentry/replay
/tests/sentry/toolbar/ @getsentry/replay
/src/sentry/templates/sentry/toolbar/ @getsentry/replay
/src/sentry/toolbar/ @getsentry/replay
/tests/sentry/toolbar/ @getsentry/replay
/static/app/components/devtoolbar/ @getsentry/replay-frontend
/src/sentry/middleware/devtoolbar.py @getsentry/replay-backend
/tests/sentry/middleware/test_devtoolbar.py @getsentry/replay-backend
## End of DevToolbar


## Misc Replay
/static/app/components/analyticsArea.tsx @getsentry/replay-frontend
/static/app/components/analyticsArea.spec.tsx @getsentry/replay-frontend
## End of Misc Replay


## Integrations
/src/sentry/sentry_apps/ @getsentry/product-owners-settings-integrations @getsentry/ecosystem
/tests/sentry/sentry_apps @getsentry/product-owners-settings-integrations @getsentry/ecosystem
Expand Down
32 changes: 32 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
24.11.2
-------

### Various fixes & improvements

- fix(dashboards): Abbreviate `LineChartWidget` Y axis integers (#81937) by @gggritso
- Revert "chore(profiling): remove profiling.stack_trace_rules.allowed_project_ids option (#81903)" (d0bea1aa) by @getsentry-bot
- feat(widget-builder): Add limit field to widget builder hook (#81944) by @nikkikapadia
- fix(alerts): Fix EAP alert filter bar to behave more like explore (#81946) by @edwardgou-sentry
- feat(alerts): Renames eap metrics in ui to spans (#81917) by @edwardgou-sentry
- feat(alerts): Limits eap alert time windows and periods (#81916) by @edwardgou-sentry
- chore(insights): Remove bundle analysis UI flag (#81932) by @gggritso
- feat(widget-builder): Batch URL param changes (#81923) by @narsaynorath
- fix(merged): Always show a link for latests event of a merged group (#81947) by @leeandher
- fix(dashboards): Add missing propagated props in `LineChartWidget` (#81935) by @gggritso
- chore(profiling): remove profiling.stack_trace_rules.allowed_project_ids option (#81903) by @viglia
- feat(new-trace): remove prefix related (#81918) by @doralchan
- :mag: nit(integration slo): cleanup tests (#81943) by @iamrajjoshi
- ref(widget-builder): Split out tests (#81949) by @narsaynorath
- fix(trace-view): Web Vitals scores (#81945) by @0Calories
- ref(insights): Simplify `SpanTimeCharts` (#81931) by @gggritso
- fix(oauth): only remove the related tokens (#81677) by @sentaur-athena
- :wrench: chore(integration slo): cleaning up tests and use util method (#81936) by @iamrajjoshi
- feat(issue summary): Change 3-dot menu to dropdown (#81928) by @roaga
- feat(sdk): Upgrade @sentry SDKs to v8.43.0 (#81925) by @aliu39
- Better logging for backpressure (#81648) by @kneeyo1
- feat(dashboards): add success message when favoriting dashboards (#81887) by @harshithadurai
- feat(ui): Add dark app loading theme (#81611) by @scttcper
- ref(dashboards): Export Widget component props (#81924) by @gggritso

_Plus 442 more_

24.11.1
-------

Expand Down
43 changes: 42 additions & 1 deletion bin/benchmark_codeowners/benchmark
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python
# isort: skip_file
# flake8: noqa: S002


"""
This script benchmarks the performance of issue owner assignment in Sentry.
Expand All @@ -15,7 +17,13 @@ import time
from sentry.models.organization import Organization
from sentry.models.projectownership import ProjectOwnership
from sentry.models.project import Project
from sentry.models.team import Team
from sentry.utils import json
import sentry_sdk
from sentry.models.projectteam import ProjectTeam

# disable sentry as it creates lots of noise in the output
sentry_sdk.init(None)


def main(code_mapping_file, event_data_file):
Expand All @@ -42,6 +50,30 @@ def main(code_mapping_file, event_data_file):
name=project_name, slug=project_slug, id=project_id, organization_id=org.id
)

# create teams for all actors
teams_to_create = []
seen_teams = set()
for rule in code_mapping["rules"]:
for owner in rule["owners"]:
team_name = owner["identifier"]
if team_name not in seen_teams:
teams_to_create.append(
Team(
name=team_name,
slug=team_name,
organization_id=org.id,
id=owner["id"],
)
)
seen_teams.add(team_name)

# delete teams from previous runs
Team.objects.filter(id__in=[team.id for team in teams_to_create]).delete()

Team.objects.bulk_create(teams_to_create)
for team in Team.objects.filter(organization_id=org.id):
ProjectTeam.objects.create(project_id=project.id, team_id=team.id)

# create a projectownership
ProjectOwnership.objects.get_or_create(
project_id=project.id,
Expand All @@ -51,9 +83,18 @@ def main(code_mapping_file, event_data_file):
event_data = get_event_data()

start = time.time()
ProjectOwnership.get_issue_owners(project.id, event_data)
issue_owners = ProjectOwnership.get_issue_owners(project.id, event_data)
elapsed_time = time.time() - start
print(f"Time taken: {elapsed_time:.6f} seconds") # noqa
print("Ownership rules:")
for rule, teams, rule_type in issue_owners:
print(f"\nRule:")
print(f" Type: {rule_type}")
print(f" Pattern: {rule.matcher.pattern}")
print(" Teams:")
for team in teams: # type: ignore[assignment]
if isinstance(team, Team): # Only handle Team objects
print(f" - {team.name} (id: {team.id})")


if __name__ == "__main__":
Expand Down
23 changes: 13 additions & 10 deletions fixtures/sdk_crash_detection/crash_event_react_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ def get_frames(filename: str) -> Sequence[MutableMapping[str, str]]:
return frames


def get_exception(
frames: Sequence[Mapping[str, str]],
mechanism_type: str = "onerror",
) -> dict[str, object]:
return {
"type": "Error",
"value": "Uncaught Thrown Error",
"stacktrace": {"frames": frames},
"mechanism": {"type": mechanism_type, "handled": False},
}


def get_crash_event(
filename="/Users/sentry.user/git-repos/sentry-react-native/dist/js/client.js", **kwargs
) -> dict[str, object]:
Expand All @@ -60,16 +72,7 @@ def get_crash_event_with_frames(frames: Sequence[Mapping[str, str]], **kwargs) -
"platform": "javascript",
"message": "",
"environment": "dev",
"exception": {
"values": [
{
"type": "Error",
"value": "Uncaught Thrown Error",
"stacktrace": {"frames": frames},
"mechanism": {"type": "onerror", "handled": False},
}
]
},
"exception": {"values": [get_exception(frames)]},
"key_id": "3554525",
"level": "fatal",
"contexts": {
Expand Down
8 changes: 2 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ ignore_missing_imports = true
module = [
"sentry.api.base",
"sentry.api.bases.organization_events",
"sentry.api.bases.organizationmember",
"sentry.api.bases.team",
"sentry.api.endpoints.accept_organization_invite",
"sentry.api.endpoints.auth_config",
Expand All @@ -146,18 +145,15 @@ module = [
"sentry.api.endpoints.organization_releases",
"sentry.api.endpoints.organization_request_project_creation",
"sentry.api.endpoints.organization_search_details",
"sentry.api.endpoints.organization_sessions",
"sentry.api.endpoints.organization_stats",
"sentry.api.endpoints.project_index",
"sentry.api.endpoints.project_ownership",
"sentry.api.endpoints.project_release_files",
"sentry.api.endpoints.project_repo_path_parsing",
"sentry.api.endpoints.project_rule_preview",
"sentry.api.endpoints.project_rules_configuration",
"sentry.api.endpoints.project_servicehook_stats",
"sentry.api.endpoints.project_transaction_names",
"sentry.api.endpoints.team_details",
"sentry.api.endpoints.team_release_count",
"sentry.api.endpoints.user_subscriptions",
"sentry.api.event_search",
"sentry.api.helpers.group_index.index",
Expand Down Expand Up @@ -302,8 +298,6 @@ module = [
"sentry.snuba.metrics.datasource",
"sentry.snuba.metrics.fields.base",
"sentry.snuba.metrics.query_builder",
"sentry.snuba.sessions_v2",
"sentry.snuba.spans_indexed",
"sentry.snuba.spans_metrics",
"sentry.tagstore.snuba.backend",
"sentry.tagstore.types",
Expand Down Expand Up @@ -448,11 +442,13 @@ module = [
"sentry.reprocessing2",
"sentry.runner.*",
"sentry.search.snuba.backend",
"sentry.seer.similarity.utils",
"sentry.sentry_metrics.consumers.indexer.slicing_router",
"sentry.snuba.metrics.extraction",
"sentry.stacktraces.platform",
"sentry.tasks.beacon",
"sentry.tasks.commit_context",
"sentry.tasks.embeddings_grouping.backfill_seer_grouping_records_for_project",
"sentry.tasks.on_demand_metrics",
"sentry.tasks.reprocessing2",
"sentry.tasks.store",
Expand Down
2 changes: 1 addition & 1 deletion requirements-base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ sentry-kafka-schemas>=0.1.122
sentry-ophio==1.0.0
sentry-protos>=0.1.37
sentry-redis-tools>=0.1.7
sentry-relay>=0.9.3
sentry-relay>=0.9.4
sentry-sdk[http2]>=2.19.2
slack-sdk>=3.27.2
snuba-sdk>=3.0.43
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev-frozen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ sentry-kafka-schemas==0.1.122
sentry-ophio==1.0.0
sentry-protos==0.1.39
sentry-redis-tools==0.1.7
sentry-relay==0.9.3
sentry-relay==0.9.4
sentry-sdk==2.19.2
sentry-usage-accountant==0.0.10
simplejson==3.17.6
Expand Down
2 changes: 1 addition & 1 deletion requirements-frozen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ sentry-kafka-schemas==0.1.122
sentry-ophio==1.0.0
sentry-protos==0.1.39
sentry-redis-tools==0.1.7
sentry-relay==0.9.3
sentry-relay==0.9.4
sentry-sdk==2.19.2
sentry-usage-accountant==0.0.10
simplejson==3.17.6
Expand Down
28 changes: 19 additions & 9 deletions src/sentry/api/bases/organizationmember.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

from typing import Any
from typing import Any, NotRequired, TypedDict

from rest_framework import serializers
from rest_framework.fields import empty
from rest_framework.request import Request

from sentry import features
Expand Down Expand Up @@ -65,7 +66,7 @@ def to_internal_value(self, data):
return data
return super().to_internal_value(data)

def run_validation(self, data):
def run_validation(self, data=empty):
if data == "me":
return data
return super().run_validation(data)
Expand All @@ -75,6 +76,15 @@ class MemberSerializer(serializers.Serializer):
id = MemberIdField(min_value=0, max_value=BoundedAutoField.MAX_VALUE, required=True)


class _FilterKwargs(TypedDict):
organization: Organization
user_id: NotRequired[int]
user_is_active: NotRequired[bool]
id: NotRequired[int | str]
organization_id: NotRequired[int]
invite_status: NotRequired[int]


class OrganizationMemberEndpoint(OrganizationEndpoint):
def convert_args(
self,
Expand Down Expand Up @@ -105,16 +115,16 @@ def _get_member(
member_id: int | str,
invite_status: InviteStatus | None = None,
) -> OrganizationMember:
args = []
kwargs = dict(organization=organization)
kwargs: _FilterKwargs = {"organization": organization}

if member_id == "me":
kwargs.update(user_id=request.user.id, user_is_active=True)
kwargs["user_id"] = request.user.id
kwargs["user_is_active"] = True
else:
kwargs.update(id=member_id, organization_id=organization.id)
kwargs["id"] = member_id
kwargs["organization_id"] = organization.id

if invite_status:
kwargs.update(invite_status=invite_status.value)
kwargs["invite_status"] = invite_status.value

om = OrganizationMember.objects.filter(*args, **kwargs).get()
return om
return OrganizationMember.objects.filter(**kwargs).get()
1 change: 1 addition & 0 deletions src/sentry/api/endpoints/organization_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ def get(self, request: Request, organization) -> Response:
use_aggregate_conditions = request.GET.get("allowAggregateConditions", "1") == "1"
# Only works when dataset == spans
use_rpc = request.GET.get("useRpc", "0") == "1"
sentry_sdk.set_tag("performance.use_rpc", use_rpc)

def _data_fn(scoped_dataset, offset, limit, query) -> dict[str, Any]:
if use_rpc and dataset == spans_eap:
Expand Down
7 changes: 5 additions & 2 deletions src/sentry/api/endpoints/organization_releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,11 @@ def post(self, request: Request, organization) -> Response:
:pparam string organization_id_or_slug: the id or slug of the organization the
release belongs to.
:param string version: a version identifier for this release. Can
be a version number, a commit hash etc.
:param string version: a version identifier for this release. Can
be a version number, a commit hash etc. It cannot contain certain
whitespace characters (`\\r`, `\\n`, `\\f`, `\\x0c`, `\\t`) or any
slashes (`\\`, `/`). The version names `.`, `..` and `latest` are also
reserved, and cannot be used.
:param string ref: an optional commit reference. This is useful if
a tagged version has been provided.
:param url url: a URL that points to the release. This can be the
Expand Down
3 changes: 1 addition & 2 deletions src/sentry/api/endpoints/organization_sessions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from contextlib import contextmanager

import sentry_sdk
from django.utils.datastructures import MultiValueDict
from drf_spectacular.utils import extend_schema
from rest_framework.exceptions import ParseError
from rest_framework.request import Request
Expand Down Expand Up @@ -118,7 +117,7 @@ def build_sessions_query(
raise NoProjects("No projects available") # give it a description

# HACK to prevent front-end crash when release health is sessions-based:
query_params = MultiValueDict(request.GET)
query_params = request.GET.copy()
if not release_health.backend.is_metrics_based() and request.GET.get("interval") == "10s":
query_params["interval"] = "1m"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from rest_framework.request import Request
from rest_framework.response import Response

from sentry import features
from sentry.api.api_owners import ApiOwner
from sentry.api.api_publish_status import ApiPublishStatus
from sentry.api.base import region_silo_endpoint
Expand All @@ -22,10 +21,6 @@ class ProjectBackfillSimilarIssuesEmbeddingsRecords(ProjectEndpoint):
}

def post(self, request: Request, project: Project) -> Response:
# needs to have the flag to run
if not features.has("projects:similarity-embeddings-backfill", project):
return Response(status=404)

# needs to either be a superuser or be in single org mode
if not (is_active_superuser(request) or settings.SENTRY_SINGLE_ORGANIZATION):
return Response(status=404)
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/api/endpoints/project_servicehook_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def get(self, request: Request, project, hook_id) -> Response:

stat_args = self._parse_args(request)

stats = {}
stats: dict[int, dict[str, int]] = {}
for model, name in ((TSDBModel.servicehook_fired, "total"),):
result = tsdb.get_range(
result = tsdb.backend.get_range(
model=model,
keys=[hook.id],
**stat_args,
Expand Down
8 changes: 4 additions & 4 deletions src/sentry/api/endpoints/team_release_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ def get(self, request: Request, team) -> Response:
)

agg_project_counts = {}
project_avgs = defaultdict(int)
this_week_totals = defaultdict(int)
project_avgs: dict[int, float] = defaultdict(int)
this_week_totals: dict[int, int] = defaultdict(int)
this_week_start = now() - timedelta(days=7)
for row in per_project_daily_release_counts:
project_avgs[row["projects"]] += row["count"]
agg_project_counts[str(row["bucket"].date())] = row["count"]
if row["bucket"] >= this_week_start:
this_week_totals[row["projects"]] += row["count"]

for row in project_avgs:
project_avgs[row] = (project_avgs[row] / (end - start).days) * 7
for project_id in project_avgs:
project_avgs[project_id] = (project_avgs[project_id] / (end - start).days) * 7

current_day = start.date()
end_date = end.date()
Expand Down
Loading

0 comments on commit 5b4c4ea

Please sign in to comment.