aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-07-12 19:45:41 +0100
committerChristopher Baines <mail@cbaines.net>2019-07-12 19:49:26 +0100
commit743cec7cb675dc6cc792a01daf898c011fc20fc7 (patch)
tree2040ed787544470a2525307e2f7479d3f29e5a90 /guix-data-service
parent1b5db7adac298e4f0d7e6c9024fc31ebabb4a994 (diff)
downloaddata-service-743cec7cb675dc6cc792a01daf898c011fc20fc7.tar
data-service-743cec7cb675dc6cc792a01daf898c011fc20fc7.tar.gz
Associate a name with database connections
This helps when working out which connection to the database is doing what.
Diffstat (limited to 'guix-data-service')
-rw-r--r--guix-data-service/database.scm8
-rw-r--r--guix-data-service/jobs/load-new-guix-revision.scm1
-rw-r--r--guix-data-service/web/controller.scm2
3 files changed, 8 insertions, 3 deletions
diff --git a/guix-data-service/database.scm b/guix-data-service/database.scm
index ab6758b..acc6dea 100644
--- a/guix-data-service/database.scm
+++ b/guix-data-service/database.scm
@@ -24,10 +24,12 @@
(define pg-conn-finish
(@@ (squee) pg-conn-finish))
-(define (with-postgresql-connection f)
+(define* (with-postgresql-connection name f)
(define paramstring
- (or (getenv "GUIX_DATA_SERVICE_DATABASE_PARAMSTRING")
- "dbname=guix_data_service user=guix_data_service"))
+ (string-append
+ (or (getenv "GUIX_DATA_SERVICE_DATABASE_PARAMSTRING")
+ "dbname=guix_data_service user=guix_data_service")
+ " application_name='guix-data-service " name "'"))
(let* ((conn (connect-to-postgres-paramstring paramstring)))
(with-throw-handler
diff --git a/guix-data-service/jobs/load-new-guix-revision.scm b/guix-data-service/jobs/load-new-guix-revision.scm
index 4990208..8c53183 100644
--- a/guix-data-service/jobs/load-new-guix-revision.scm
+++ b/guix-data-service/jobs/load-new-guix-revision.scm
@@ -703,6 +703,7 @@ ORDER BY load_new_guix_revision_jobs.id DESC")
(lambda ()
(let ((result
(with-postgresql-connection
+ (simple-format #f "load-new-guix-revision ~A logging" id)
(lambda (logging-conn)
(insert-empty-log-entry logging-conn id)
(let ((logging-port (log-port id logging-conn)))
diff --git a/guix-data-service/web/controller.scm b/guix-data-service/web/controller.scm
index 6cdcd8b..66bc893 100644
--- a/guix-data-service/web/controller.scm
+++ b/guix-data-service/web/controller.scm
@@ -568,6 +568,7 @@
#t
(lambda ()
(with-postgresql-connection
+ "web healthcheck"
(lambda (conn)
(number?
(string->number
@@ -585,6 +586,7 @@
500))))
(_
(with-postgresql-connection
+ "web"
(lambda (conn)
(controller-with-database-connection request
method-and-path-components