feat: take the Sentry DSN from the environment - #13
Merged
Conversation
A DSN carries the key that authorises sending events, which makes it the one
Sentry setting that is a credential -- and until now the only way to give Doppel
one was to write it into a document the admin API returns and the store keeps.
`DOPPEL_SENTRY_DSN` provides it instead, or replaces what `sentry.dsn` says.
The environment wins, the same way `DOPPEL_ADMIN_TOKENS` wins over `admin.tokens`:
that is how a deployment overrides a document it may not be able to edit. Which
source won goes in the startup line beside the redacted DSN, because "sentry
reporting enabled" does not answer the question an operator has when it is the
wrong DSN.
An empty variable counts as unset and leaves `sentry.dsn` in force. Deliberately
that direction: `DOPPEL_SENTRY_DSN=${SENTRY_DSN}` with nothing behind `SENTRY_DSN`
is a compose file that means nothing by it, and silently switching error reporting
off is the worse reading of it. Turning it off is still `dsn: ""`, or no section.
Doppel reads its own name rather than the conventional `SENTRY_DSN`: a variable
sitting in the environment for the service beside this one should not make this one
start reporting to it.
Read at startup and not merged into `Config`, like the other two environment
values -- the revision is a hash of the document, so folding the environment into
it would make two instances reading one stored document disagree about the
revision. Validation stays where it was, at the client: the crate that knows what
a DSN must parse as is also the one that can redact it in the error.
Five unit tests on the precedence and two through the built binary, which is the
only place the variable is actually read from a process. Mutation-checked by
ignoring the environment: three tests fail, including the end-to-end one.
lorem-dev
force-pushed
the
feat/sentry-env
branch
from
August 14, 2026 09:09
7d10bd9 to
a6c0779
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DOPPEL_SENTRY_DSNprovides the Sentry DSN, or replaces the one in the document.Why
A DSN carries the key that authorises sending events, so it is the one Sentry
setting that is a credential. Until now the only way to give Doppel one was to
write it into a document the admin API returns and the store keeps -- which is the
same objection
DOPPEL_ADMIN_TOKENSalready answers for tokens.The rules, and why each is the way round it is
The environment wins over
sentry.dsn. That is how a deployment overrides adocument it may not be able to edit, and it is the precedence the admin tokens
already have.
An empty variable counts as unset and leaves
sentry.dsnin force.DOPPEL_SENTRY_DSN=${SENTRY_DSN}with nothing behindSENTRY_DSNis a composefile that means nothing by it, and silently switching error reporting off is the
worse reading. Turning it off is still
dsn: "", or no section at all.Doppel reads its own name, not the conventional
SENTRY_DSN. A variablesitting in the environment for the service beside this one should not make this
one start reporting to it.
The source is logged. "sentry reporting enabled" with a redacted DSN does not
answer the question an operator has when it is the wrong DSN:
{"level":"INFO","fields":{"message":"sentry reporting enabled", "dsn":"https://<redacted>@sentry.example.com/1","source":"DOPPEL_SENTRY_DSN"}}Read at startup, not merged into
Config, like the other two environmentvalues: the revision is a hash of the document, so folding the environment in
would make two instances reading one stored document disagree about it.
Validation stays at the client. The crate that knows what a DSN has to parse
as is also the only one that can redact the key when it does not.
Verification
make gateclean, with both feature configurations ofdoppel-telemetry-- thedefault build and
--features sentry. Five unit tests on the precedence, twothrough the built binary, which is the only place a variable is really read from a
process: one asserts the source is named and the key does not leak, the other that
an empty variable leaves a configured DSN alone.
Mutation-checked by ignoring the environment entirely: three tests fail, including
the end-to-end one.
Documented in the observability page, the configuration reference, the field's own
doc comment (so the schema and the generated parameter page carry it) and two lines
in the README beside
DOPPEL_EXTERNAL_URL.