Skip to content

Commit

Permalink
Configure SENTRY_TRACES_SAMPLE_RATE via env
Browse files Browse the repository at this point in the history
  • Loading branch information
r4victor committed Nov 10, 2023
1 parent 21935be commit 005a83e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
11 changes: 1 addition & 10 deletions src/dstack/_internal/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,13 @@ def create_app() -> FastAPI:
dsn=settings.SENTRY_DSN,
environment=settings.SERVER_ENVIRONMENT,
enable_tracing=True,
before_send_transaction=filter_sentry_transactions,
traces_sample_rate=0.25,
traces_sample_rate=settings.SENTRY_TRACES_SAMPLE_RATE,
)

app = FastAPI(docs_url="/api/docs", lifespan=lifespan)
return app


def filter_sentry_transactions(event, hint):
url_string = event["request"]["url"]
parsed_url = urlparse(url_string)
if parsed_url.path == "/api/healthcheck":
return None
return event


@asynccontextmanager
async def lifespan(app: FastAPI):
configure_logging()
Expand Down
2 changes: 2 additions & 0 deletions src/dstack/_internal/server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
DEFAULT_GATEWAY_NAME = "default-gateway"

SENTRY_DSN = os.getenv("DSTACK_SENTRY_DSN")
SENTRY_TRACES_SAMPLE_RATE = float(os.getenv("DSTACK_SENTRY_TRACES_SAMPLE_RATE", 0.1))


DEFAULT_CREDS_DISABLED = os.getenv("DSTACK_DEFAULT_CREDS_DISABLED") is not None
DEFAULT_CREDS_ENABLED = not DEFAULT_CREDS_DISABLED

0 comments on commit 005a83e

Please sign in to comment.