Skip to content

Commit

Permalink
Added support to Sentry communicate using custom CA certificates.
Browse files Browse the repository at this point in the history
  • Loading branch information
srtab committed Dec 12, 2024
1 parent f9c6d79 commit 08c6240
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`<br>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`<br>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`<br>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`<br>Default: "runc" |
| **DAIV_SANDBOX_KEEP_TEMPLATE** | Whether to keep the execution template after finishing. | Default: False |

## Usage

Expand Down
8 changes: 6 additions & 2 deletions daiv_sandbox/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion daiv_sandbox/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()],
)
Expand Down

0 comments on commit 08c6240

Please sign in to comment.