Skip to content

Commit

Permalink
add app name to database connection string
Browse files Browse the repository at this point in the history
this makes it easier to see where db conns are coming from when viewing
psql connections
  • Loading branch information
longhotsummer committed Aug 22, 2023
1 parent 3769bab commit cd32e2c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions peachjam/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@
"default": default_db_config,
"gazettes_africa": gazette_db_config,
}
# descriptive name for this application in psql's pg_stat_activity output, to help link connections to apps
db_app_name = "-".join(
[slugify(PEACHJAM["APP_NAME"]), os.environ.get("DYNO", "django")]
)
for cfg in DATABASES.values():
cfg.setdefault("OPTIONS", {})["options"] = f"-c application_name={db_app_name}"


# Password validation
Expand Down

0 comments on commit cd32e2c

Please sign in to comment.