Skip to content

Commit

Permalink
Merge branch 'master' into nar/feat/widget-builder-batch-url-param-ch…
Browse files Browse the repository at this point in the history
…anges
  • Loading branch information
narsaynorath committed Dec 10, 2024
2 parents 8c0d602 + dbb9929 commit 3a7e202
Show file tree
Hide file tree
Showing 50 changed files with 962 additions and 1,078 deletions.
2 changes: 1 addition & 1 deletion build-utils/sentry-instrumentation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-env node */
import type {Span} from '@sentry/core';
import type * as Sentry from '@sentry/node';
import type {Span} from '@sentry/types';
import crypto from 'node:crypto';
import https from 'node:https';
import os from 'node:os';
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
"@sentry-internal/rrweb": "2.26.0",
"@sentry-internal/rrweb-player": "2.26.0",
"@sentry-internal/rrweb-snapshot": "2.26.0",
"@sentry/core": "8.39.0-beta.0",
"@sentry/node": "8.39.0-beta.0",
"@sentry/react": "8.39.0-beta.0",
"@sentry/core": "8.43.0",
"@sentry/node": "8.43.0",
"@sentry/react": "8.43.0",
"@sentry/release-parser": "^1.3.1",
"@sentry/status-page-list": "^0.3.0",
"@sentry/types": "8.39.0-beta.0",
"@sentry/utils": "8.39.0-beta.0",
"@sentry/types": "8.43.0",
"@sentry/utils": "8.43.0",
"@sentry/webpack-plugin": "^2.22.4",
"@spotlightjs/spotlight": "^2.0.0-alpha.1",
"@tanstack/react-query": "^5.56.2",
Expand Down Expand Up @@ -179,7 +179,7 @@
"@emotion/eslint-plugin": "^11.12.0",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.15",
"@sentry/jest-environment": "6.0.0",
"@sentry/profiling-node": "8.39.0-beta.0",
"@sentry/profiling-node": "8.43.0",
"@styled/typescript-styled-plugin": "^1.0.1",
"@testing-library/dom": "10.1.0",
"@testing-library/jest-dom": "6.4.5",
Expand Down
4 changes: 3 additions & 1 deletion src/sentry/api/endpoints/api_authorizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def delete(self, request: Request) -> Response:

with outbox_context(transaction.atomic(using=router.db_for_write(ApiToken)), flush=False):
for token in ApiToken.objects.filter(
user_id=request.user.id, application=auth.application_id
user_id=request.user.id,
application=auth.application_id,
scoping_organization_id=auth.organization_id,
):
token.delete()

Expand Down
14 changes: 2 additions & 12 deletions src/sentry/integrations/slack/utils/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,10 @@
SLACK_LINK_IDENTITY_MSG_SUCCESS_DATADOG_METRIC,
SLACK_METRIC_ALERT_FAILURE_DATADOG_METRIC,
SLACK_METRIC_ALERT_SUCCESS_DATADOG_METRIC,
record_lifecycle_termination_level,
)
from sentry.integrations.slack.sdk_client import SlackSdkClient
from sentry.integrations.slack.spec import SlackMessagingSpec
from sentry.integrations.slack.utils.errors import (
SLACK_SDK_HALT_ERROR_CATEGORIES,
unpack_slack_api_error,
)
from sentry.models.options.organization_option import OrganizationOption
from sentry.utils import metrics

Expand Down Expand Up @@ -176,14 +173,7 @@ def send_incident_alert_notification(
lifecycle.add_extras(log_params)
# If the error is a channel not found or archived, we can halt the flow
# This means that the channel was deleted or archived after the alert rule was created
if (
(reason := unpack_slack_api_error(e))
and reason is not None
and reason in SLACK_SDK_HALT_ERROR_CATEGORIES
):
lifecycle.record_halt(reason.message)
else:
lifecycle.record_failure(e)
record_lifecycle_termination_level(lifecycle, e)

else:
success = True
Expand Down
31 changes: 30 additions & 1 deletion src/sentry/processing/backpressure/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class ServiceMemory:
used: int
available: int
percentage: float
host: str | None = None
port: int | None = None

def __init__(self, name: str, used: int, available: int):
self.name = name
Expand All @@ -21,6 +23,12 @@ def __init__(self, name: str, used: int, available: int):
self.percentage = used / available


@dataclass
class NodeInfo:
host: str | None
port: int | None


def query_rabbitmq_memory_usage(host: str) -> ServiceMemory:
"""Returns the currently used memory and the memory limit of a
RabbitMQ host.
Expand Down Expand Up @@ -51,6 +59,23 @@ def get_memory_usage(node_id: str, info: Mapping[str, Any]) -> ServiceMemory:
return ServiceMemory(node_id, memory_used, memory_available)


def get_host_port_info(node_id: str, cluster: Cluster) -> NodeInfo:
"""
Extract the host and port of the redis node in the cluster.
"""
try:
if isinstance(cluster, RedisCluster):
# RedisCluster node mapping
node = cluster.connection_pool.nodes.nodes.get(node_id)
return NodeInfo(node["host"], node["port"])
else:
# rb.Cluster node mapping
node = cluster.hosts[node_id]
return NodeInfo(node.host, node.port)
except Exception:
return NodeInfo(None, None)


def iter_cluster_memory_usage(cluster: Cluster) -> Generator[ServiceMemory, None, None]:
"""
A generator that yields redis `INFO` results for each of the nodes in the `cluster`.
Expand All @@ -65,4 +90,8 @@ def iter_cluster_memory_usage(cluster: Cluster) -> Generator[ServiceMemory, None
cluster_info = promise.value

for node_id, info in cluster_info.items():
yield get_memory_usage(node_id, info)
node_info = get_host_port_info(node_id, cluster)
memory_usage = get_memory_usage(node_id, info)
memory_usage.host = node_info.host
memory_usage.port = node_info.port
yield memory_usage
10 changes: 10 additions & 0 deletions src/sentry/processing/backpressure/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ def check_service_health(services: Mapping[str, Service]) -> MutableMapping[str,
reasons = []

logger.info("Checking service `%s` (configured high watermark: %s):", name, high_watermark)
memory = None
try:
for memory in check_service_memory(service):
if memory.percentage >= high_watermark:
reasons.append(memory)
logger.info("Checking node: %s:%s", memory.host, memory.port)
logger.info(
" name: %s, used: %s, available: %s, percentage: %s",
memory.name,
Expand All @@ -101,6 +103,14 @@ def check_service_health(services: Mapping[str, Service]) -> MutableMapping[str,
scope.set_tag("service", name)
sentry_sdk.capture_exception(e)
unhealthy_services[name] = e
host = memory.host if memory else "unknown"
port = memory.port if memory else "unknown"
logger.exception(
"Error while processing node %s:%s for service %s",
host,
port,
service,
)
else:
unhealthy_services[name] = reasons

Expand Down
2 changes: 2 additions & 0 deletions src/sentry/templates/sentry/base-react.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
</div>
</div>
{% endblock %}

{% block wrapperclass %}{{ user_theme }}{% endblock %}
11 changes: 10 additions & 1 deletion src/sentry/web/frontend/react_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ def dns_prefetch(self) -> list[str]:

def handle_react(self, request: Request, **kwargs) -> HttpResponse:
org_context = getattr(self, "active_organization", None)
react_config = get_client_config(request, org_context)

user_theme = ""
if react_config.get("user", None) and react_config["user"].get("options", {}).get(
"theme", None
):
user_theme = f"theme-{react_config['user']['options']['theme']}"

context = {
"CSRF_COOKIE_NAME": settings.CSRF_COOKIE_NAME,
"meta_tags": [
Expand All @@ -100,7 +108,8 @@ def handle_react(self, request: Request, **kwargs) -> HttpResponse:
# Since we already have it here from the OrganizationMixin, we can
# save some work and render it faster.
"org_context": org_context,
"react_config": get_client_config(request, org_context),
"react_config": react_config,
"user_theme": user_theme,
}

# Force a new CSRF token to be generated and set in user's
Expand Down
3 changes: 2 additions & 1 deletion static/app/actionCreators/dashboards.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import omit from 'lodash/omit';

import {addErrorMessage} from 'sentry/actionCreators/indicator';
import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator';
import type {Client} from 'sentry/api';
import {ALL_ACCESS_PROJECTS} from 'sentry/constants/pageFilters';
import {t} from 'sentry/locale';
Expand Down Expand Up @@ -113,6 +113,7 @@ export async function updateDashboardFavorite(
},
}
);
addSuccessMessage(isFavorited ? t('Added as favorite') : t('Removed as favorite'));
} catch (response) {
const errorResponse = response?.responseJSON ?? null;
if (errorResponse) {
Expand Down
3 changes: 1 addition & 2 deletions static/app/bootstrap/initializeSdk.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// eslint-disable-next-line simple-import-sort/imports
import * as Sentry from '@sentry/react';
import {_browserPerformanceTimeOriginMode} from '@sentry/utils';
import type {Event} from '@sentry/types';
import {type Event, _browserPerformanceTimeOriginMode} from '@sentry/core';

import {SENTRY_RELEASE_VERSION, SPA_DSN} from 'sentry/constants';
import type {Config} from 'sentry/types/system';
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/badge/featureBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Fragment, type ReactNode} from 'react';
import {useTheme} from '@emotion/react';
import styled from '@emotion/styled';
import type {SeverityLevel} from '@sentry/core';
import {captureException, withScope} from '@sentry/react';
import type {SeverityLevel} from '@sentry/types';

import Badge from 'sentry/components/badge/badge';
import CircleIndicator from 'sentry/components/circleIndicator';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useCallback, useEffect, useState} from 'react';
import type {ReplayRecordingMode} from '@sentry/core';
import type {replayIntegration} from '@sentry/react';
import type {ReplayRecordingMode} from '@sentry/types';

import useConfiguration from 'sentry/components/devtoolbar/hooks/useConfiguration';
import {useSessionStorage} from 'sentry/utils/useSessionStorage';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Client, Scope} from '@sentry/types';
import type {Client, Scope} from '@sentry/core';

type V8Carrier = {
stack: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Event} from '@sentry/types';
import type {Event} from '@sentry/core';

import {useApiQuery} from 'sentry/utils/queryClient';
import useOrganization from 'sentry/utils/useOrganization';
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/featureFeedback/feedbackModal.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {Fragment, useCallback, useMemo, useState} from 'react';
import {css, useTheme} from '@emotion/react';
import styled from '@emotion/styled';
import type {Event} from '@sentry/core';
import {
BrowserClient,
captureFeedback,
defaultStackParser,
getDefaultIntegrations,
makeFetchTransport,
} from '@sentry/react';
import type {Event} from '@sentry/types';
import cloneDeep from 'lodash/cloneDeep';

import {addSuccessMessage} from 'sentry/actionCreators/indicator';
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/feedback/widget/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Event} from '@sentry/types';
import type {Event} from '@sentry/core';

/**
* NOTE: These types are still considered Beta and subject to change.
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/group/externalIssueForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {Span} from '@sentry/core';
import * as Sentry from '@sentry/react';
import type {Span} from '@sentry/types';

import {addSuccessMessage} from 'sentry/actionCreators/indicator';
import type DeprecatedAsyncComponent from 'sentry/components/deprecatedAsyncComponent';
Expand Down
Loading

0 comments on commit 3a7e202

Please sign in to comment.