Skip to content

Commit

Permalink
Remove SENTRY_DSN from required env vars
Browse files Browse the repository at this point in the history
Why these changes are being introduced:

For local development, or external users of this application, it does not make sense
to require a SENTRY_DSN environment variable.  While setting this to 'none' would
satisfy the config setup, and not use Sentry, it feels unnecessary.

How this addresses that need:
* Moves SENTRY_DSN to optional env vars in Config class

Side effects of this change:
* SENTRY_DSN is no longer required as an env var, but providing it will still get
picked up used

Relevant ticket(s):
* None
  • Loading branch information
ghukill committed Dec 12, 2024
1 parent ff749b6 commit 58d8f0b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ WORKSPACE=dev
RECORD_SKIP_LIST=<oai-pmh-id1> <oai-pmh-id2>

# Sets the interval for logging status updates as records are written to the output file. Defaults to 1000, which will log a status update for every thousandth record.
STATUS_UPDATE_INTERVAL = 1000
STATUS_UPDATE_INTERVAL=1000

# If set to a valid Sentry DSN, enables Sentry exception monitoring This is not needed for local development.
SENTRY_DSN = <sentry-dsn-for-oai-pmh-harvester>
# If set to a valid Sentry DSN, enables Sentry exception monitoring. This can also be set to 'none'.
SENTRY_DSN=<sentry-dsn-for-oai-pmh-harvester>
```

## CLI commands
Expand Down
4 changes: 2 additions & 2 deletions harvester/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@


class Config:
REQUIRED_ENV_VARS = ("WORKSPACE", "SENTRY_DSN")
OPTIONAL_ENV_VARS = ("RECORD_SKIP_LIST", "STATUS_UPDATE_INTERVAL")
REQUIRED_ENV_VARS = ("WORKSPACE",)
OPTIONAL_ENV_VARS = ("RECORD_SKIP_LIST", "SENTRY_DSN", "STATUS_UPDATE_INTERVAL")

def __init__(self, logger: logging.Logger | None = None):
"""Set root logger as default when creating class instance."""
Expand Down
8 changes: 0 additions & 8 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ def test_config_check_required_env_vars_success(config):
config.check_required_env_vars()


def test_config_check_required_env_vars_error(config, monkeypatch):
monkeypatch.delenv("SENTRY_DSN")
with pytest.raises(
OSError, match="Missing required environment variables: SENTRY_DSN"
):
config.check_required_env_vars()


def test_config_env_var_access_success(config):
assert config.STATUS_UPDATE_INTERVAL == "1000"

Expand Down

0 comments on commit 58d8f0b

Please sign in to comment.