From 08c62404be510585c480fa5457abb77b1a4202a1 Mon Sep 17 00:00:00 2001 From: Sandro Date: Wed, 11 Dec 2024 23:58:56 +0000 Subject: [PATCH] Added support to Sentry communicate using custom CA certificates. --- CHANGELOG.md | 5 +++++ README.md | 18 ++++++++++-------- daiv_sandbox/config.py | 8 ++++++-- daiv_sandbox/main.py | 4 +++- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da47434..4736e2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Added `SENTRY_CA_CERTS` configuration to support Sentry communicate through SSL from custom CA. +- Added `SENTRY_ENABLE_TRACING` configuration to enable Sentry tracing. + ## [0.1.0-rc.5] - 2024-12-11 ### Added diff --git a/README.md b/README.md index 73a703c..6e58d64 100644 --- a/README.md +++ b/README.md @@ -38,14 +38,16 @@ $ docker run --rm -d -p 8000:8000 -e DAIV_SANDBOX_API_KEY=my-secret-api-key -e D All settings are configurable via environment variables. The available settings are: -| Environment Variable | Description | Options/Default | -| ----------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------- | -| **DAIV_SANDBOX_API_KEY** | The API key required to access the sandbox API. | | -| **DAIV_SANDBOX_ENVIRONMENT** | The deployment environment. | Options: `local`, `staging`, `production`
Default: "local" | -| **DAIV_SANDBOX_SENTRY_DSN** | The DSN for Sentry error tracking. | Optional | -| **DAIV_SANDBOX_MAX_EXECUTION_TIME** | The maximum allowed execution time for commands in seconds. | Default: 600 | -| **DAIV_SANDBOX_RUNTIME** | The container runtime to use. | Options: `runc`, `runsc`
Default: "runc" | -| **DAIV_SANDBOX_KEEP_TEMPLATE** | Whether to keep the execution template after finishing. | Default: False | +| Environment Variable | Description | Options/Default | +| -------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------- | +| **DAIV_SANDBOX_API_KEY** | The API key required to access the sandbox API. | | +| **DAIV_SANDBOX_ENVIRONMENT** | The deployment environment. | Options: `local`, `staging`, `production`
Default: "local" | +| **DAIV_SANDBOX_SENTRY_DSN** | The DSN for Sentry error tracking. | Optional | +| **DAIV_SANDBOX_SENTRY_CA_CERTS** | The CA certificates for Sentry communication. | Optional | +| **DAIV_SANDBOX_SENTRY_ENABLE_TRACING** | Whether to enable tracing for Sentry error tracking. | Default: False | +| **DAIV_SANDBOX_MAX_EXECUTION_TIME** | The maximum allowed execution time for commands in seconds. | Default: 600 | +| **DAIV_SANDBOX_RUNTIME** | The container runtime to use. | Options: `runc`, `runsc`
Default: "runc" | +| **DAIV_SANDBOX_KEEP_TEMPLATE** | Whether to keep the execution template after finishing. | Default: False | ## Usage diff --git a/daiv_sandbox/config.py b/daiv_sandbox/config.py index fef5e92..fb9c63e 100644 --- a/daiv_sandbox/config.py +++ b/daiv_sandbox/config.py @@ -7,13 +7,17 @@ class Settings(BaseSettings): model_config = SettingsConfigDict(secrets_dir="/run/secrets", env_prefix="DAIV_SANDBOX_") + # Environment + ENVIRONMENT: Literal["local", "staging", "production"] = "local" + # API API_V1_STR: str = "/api/v1" API_KEY: str - # Environment - ENVIRONMENT: Literal["local", "staging", "production"] = "local" + # Sentry SENTRY_DSN: HttpUrl | None = None + SENTRY_CA_CERTS: str | None = None + SENTRY_ENABLE_TRACING: bool = False # Execution MAX_EXECUTION_TIME: int = 600 # seconds diff --git a/daiv_sandbox/main.py b/daiv_sandbox/main.py index 6ea6443..d32eafb 100644 --- a/daiv_sandbox/main.py +++ b/daiv_sandbox/main.py @@ -35,7 +35,9 @@ sentry_sdk.init( dsn=str(settings.SENTRY_DSN), environment=settings.ENVIRONMENT, - enable_tracing=True, + enable_tracing=settings.SENTRY_ENABLE_TRACING, + profiles_sample_rate=1.0 if settings.SENTRY_ENABLE_TRACING else 0.0, + ca_certs=settings.SENTRY_CA_CERTS, release=__version__, integrations=[FastApiIntegration()], )