Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,6 @@ tests/sentry/api/endpoints/test_organization_attribute_mappings.py @get


## Telemetry Experience
/src/sentry/autopilot/ @getsentry/telemetry-experience
/tests/sentry/autopilot/ @getsentry/telemetry-experience
/src/sentry/api/endpoints/organization_sessions.py @getsentry/telemetry-experience
/tests/snuba/api/endpoints/test_organization_sessions.py @getsentry/telemetry-experience
/src/sentry/api/endpoints/organization_sampling_project_span_counts.py @getsentry/telemetry-experience
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,6 @@ module = [
"sentry.audit_log.events",
"sentry.audit_log.manager",
"sentry.audit_log.register",
"sentry.autopilot.*",
"sentry.backup.*",
"sentry.billing.*",
"sentry.cache.*",
Expand Down Expand Up @@ -1919,7 +1918,6 @@ module = [
"tests.sentry.auth.test_system",
"tests.sentry.auth_v2.utils.*",
"tests.sentry.autofix.*",
"tests.sentry.autopilot.*",
"tests.sentry.backup.*",
"tests.sentry.billing.*",
"tests.sentry.buffer.*",
Expand Down
3 changes: 2 additions & 1 deletion src/apigw/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def load_config(app: App) -> None:
app.config.proxy.max_concurrency = int(os.environ.get("APIGW_PROXY_MAX_CONCURRENCY", 512))
app.config.proxy.max_failures = int(os.environ.get("APIGW_PROXY_MAX_FAILURES", 16))
app.config.proxy.failure_window = int(os.environ.get("APIGW_PROXY_FAILURE_WINDOW", 60))
app.config.proxy.latency_buckets = [50, 100, 250, 1000, 10000, 60000]

app.config.proxy.client_max_connections = None
app.config.proxy.client_keepalive_max_connections = None
Expand Down Expand Up @@ -73,7 +74,7 @@ def load_config(app: App) -> None:

app.config.Prometheus.metrics_route_hostname = app.config.internal_fqdn
app.config.Prometheus.enable_ws_metrics = False
app.config.Prometheus.http_histogram_buckets = [35, 100, 500, 1000, 5000, "INF"]
app.config.Prometheus.http_histogram_buckets = [35, 100, 500, 1000, 5000]
app.config.Prometheus.exclude_routes = ["internal.health"]

from django.conf import settings
Expand Down
26 changes: 25 additions & 1 deletion src/apigw/proxy.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import asyncio
import time
from typing import Any, AsyncIterator
from urllib.parse import urljoin

import httpx
import prometheus_client
from emmett55 import response
from emmett55 import Pipe, current, response

from . import app
from .circuitbreaker import (
Expand Down Expand Up @@ -71,6 +72,27 @@ async def __aiter__(self) -> AsyncIterator[bytes]:
metric_cb_reject = prometheus_client.Counter(
"apigw_proxy_circuitbreaker_rejected", "Circuitbreaker rejected", labelnames=["target"]
)
metric_latency = prometheus_client.Histogram(
"apigw_proxy_latency",
"Latency histogram (ms)",
labelnames=["target"],
buckets=app.config.proxy.latency_buckets,
)


class ProxyLatencyPipe(Pipe):
@staticmethod
def track(target: str) -> None:
current._proxy_latency_data = (target, time.perf_counter_ns())

async def open_request(self) -> None:
current._proxy_latency_data = None

async def close_request(self) -> None:
if not current._proxy_latency_data:
return
target, ts = current._proxy_latency_data
metric_latency.labels(target=target).observe((time.perf_counter_ns() - ts) / 1_000_000)


def build_proxied_headers(request: Any, target: str) -> list[tuple[str, str]]:
Expand Down Expand Up @@ -154,6 +176,7 @@ async def proxy_cell_request(cell: Cell, request: Any) -> Any:
content=request.body,
timeout=timeout,
)
ProxyLatencyPipe.track(cell.name)
resp = await proxy_client.send(req, stream=True, follow_redirects=False)
if resp.status_code >= 502:
circuitbreaker.incr_failures()
Expand Down Expand Up @@ -198,6 +221,7 @@ async def proxy_control_request(request: Any) -> Any:
content=request.body,
timeout=app.config.proxy.timeout,
)
ProxyLatencyPipe.track("control")
resp = await proxy_client.send(req, stream=True, follow_redirects=False)
return await adapt_response(resp)
except asyncio.CancelledError:
Expand Down
3 changes: 2 additions & 1 deletion src/apigw/views/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
get_cell_for_organization,
get_cell_from_dsn,
)
from ..proxy import proxy_cell_request, proxy_control_request
from ..proxy import ProxyLatencyPipe, proxy_cell_request, proxy_control_request
from ..utils import abort_with_json

proxy = app.module(__name__, "proxy")
proxy.pipeline = [ProxyLatencyPipe()]


@proxy.route(
Expand Down
21 changes: 20 additions & 1 deletion src/sentry/api/endpoints/system_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"system.admin-email"
]
)
MAIL_TLS_SSL_OPTIONS = ("mail.use-tls", "mail.use-ssl")


def _is_secret(k: Key) -> bool:
Expand All @@ -42,6 +43,7 @@ class SystemOptionsEndpoint(Endpoint):

def get(self, request: Request) -> Response:
query = request.GET.get("query")
required_only = query == "is:required"
if query == "is:required":
option_list = options.filter(flag=options.FLAG_REQUIRED)
elif query:
Expand All @@ -50,12 +52,19 @@ def get(self, request: Request) -> Response:
option_list = options.all()

smtp_disabled = not is_smtp_enabled()
disable_mail_tls_ssl_pair = required_only and self.__should_disable_mail_tls_ssl_pair()

results = {}
for k in option_list:
disabled, disabled_reason = False, None

if smtp_disabled and k.name[:5] == "mail.":
if k.name in MAIL_TLS_SSL_OPTIONS and disable_mail_tls_ssl_pair:
disabled_reason, disabled = "diskPriority", True
elif (
smtp_disabled
and k.name[:5] == "mail."
and not (required_only and k.name in MAIL_TLS_SSL_OPTIONS)
):
disabled_reason, disabled = "smtpDisabled", True
elif bool(
k.flags & options.FLAG_PRIORITIZE_DISK and settings.SENTRY_OPTIONS.get(k.name)
Expand All @@ -78,6 +87,16 @@ def get(self, request: Request) -> Response:

return Response(results)

def __should_disable_mail_tls_ssl_pair(self) -> bool:
for option_name in MAIL_TLS_SSL_OPTIONS:
if not options.is_set_on_disk(option_name):
continue

if settings.SENTRY_OPTIONS[option_name] != options.lookup_key(option_name).default():
return True

return False

def has_permission(self, request: Request) -> bool:
if settings.SENTRY_SELF_HOSTED and request.user.is_superuser:
return True
Expand Down
Empty file removed src/sentry/autopilot/__init__.py
Empty file.
5 changes: 0 additions & 5 deletions src/sentry/autopilot/apps.py

This file was deleted.

27 changes: 0 additions & 27 deletions src/sentry/autopilot/grouptype.py

This file was deleted.

Empty file.
Empty file removed src/sentry/autopilot/models.py
Empty file.
Empty file.
89 changes: 0 additions & 89 deletions src/sentry/autopilot/tasks/common.py

This file was deleted.

Loading
Loading