Skip to content

Commit

Permalink
feat(devservices): Add sentry config (#80030)
Browse files Browse the repository at this point in the history
This adds devservices configs for usage with sentry. Instead of running
relay as a part of devserver, we are opting to do it in a container
which allows us to automatically import relay configs from the relay
repo. This will help in reducing the duplication of configs across
repos.
  • Loading branch information
hubertdeng123 authored Nov 1, 2024
1 parent c91243c commit a0b4609
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 5 deletions.
55 changes: 55 additions & 0 deletions devservices/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Ignored by docker compose, used by devservices
x-sentry-service-config:
version: 0.1
service_name: sentry
dependencies:
snuba:
description: Service that provides fast aggregation and query capabilities on top of Clickhouse
remote:
repo_name: snuba
branch: master
repo_link: [email protected]:getsentry/snuba.git
mode: containerized
relay:
description: Service event forwarding and ingestion service
remote:
repo_name: relay
branch: master
repo_link: [email protected]:getsentry/relay.git
mode: containerized
postgres:
description: Database used to store Sentry data
modes:
default: [snuba, postgres, relay]

services:
postgres:
image: ghcr.io/getsentry/image-mirror-library-postgres:14-alpine
environment:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_DB: sentry
command:
[
postgres,
-c,
wal_level=logical,
-c,
max_replication_slots=1,
-c,
max_wal_senders=1,
]
networks:
- devservices
volumes:
- postgres-data:/var/lib/postgresql/data
ports:
- 5432:5432
extra_hosts:
- host.docker.internal:host-gateway

networks:
devservices:
name: devservices

volumes:
postgres-data:
13 changes: 8 additions & 5 deletions src/sentry/runner/commands/devserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ def devserver(

daemons: MutableSequence[tuple[str, Sequence[str]]] = []
kafka_consumers: set[str] = set()
containers: set[str] = set()
with get_docker_client() as docker:
containers = {c.name for c in docker.containers.list(filters={"status": "running"})}

if experimental_spa:
os.environ["SENTRY_UI_DEV_ONLY"] = "1"
Expand Down Expand Up @@ -323,7 +326,9 @@ def devserver(
kafka_consumers.add("uptime-configs")

if settings.SENTRY_USE_RELAY:
daemons += [("relay", ["sentry", "devservices", "attach", "relay"])]
# TODO: Remove this once we have a better way to check if relay is running for new devservices
if "relay-relay-1" not in containers:
daemons += [("relay", ["sentry", "devservices", "attach", "relay"])]

kafka_consumers.add("ingest-events")
kafka_consumers.add("ingest-attachments")
Expand All @@ -347,9 +352,7 @@ def devserver(

# Create all topics if the Kafka eventstream is selected
if kafka_consumers:
with get_docker_client() as docker:
containers = {c.name for c in docker.containers.list(filters={"status": "running"})}
if "sentry_kafka" not in containers:
if "sentry_kafka" not in containers and "shared-kafka-kafka-1" not in containers:
raise click.ClickException(
f"""
Devserver is configured to start some kafka consumers, but Kafka
Expand All @@ -368,7 +371,7 @@ def devserver(
and run `sentry devservices up kafka`.
Alternatively, run without --workers.
"""
"""
)

from sentry.conf.types.kafka_definition import Topic
Expand Down

0 comments on commit a0b4609

Please sign in to comment.