diff options
author | Christopher Baines <mail@cbaines.net> | 2020-04-30 20:08:12 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-04-30 20:08:12 +0100 |
commit | fdbcf3169ca7196a7da8e9ac5bdfda3d53cc3b65 (patch) | |
tree | e31d67c7a485d9b811787f6dd290d9874195c92a | |
parent | e72892ee26d1d755f3289e5c8c3a187ecd6a9230 (diff) | |
download | build-coordinator-fdbcf3169ca7196a7da8e9ac5bdfda3d53cc3b65.tar build-coordinator-fdbcf3169ca7196a7da8e9ac5bdfda3d53cc3b65.tar.gz |
Avoid errors in call-with-time-tracking if the registry isn't set
-rw-r--r-- | guix-build-coordinator/datastore/sqlite.scm | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm index fa82aa1..14e656a 100644 --- a/guix-build-coordinator/datastore/sqlite.scm +++ b/guix-build-coordinator/datastore/sqlite.scm @@ -83,18 +83,21 @@ datastore)) (define (call-with-time-tracking datastore metric-name thunk) - (let* ((registry (slot-ref datastore 'metrics-registry)) - (namespaced-metric-name - (string-append "guixbuildcoordinator_" metric-name)) - (metric - (or (metrics-registry-fetch-metric registry namespaced-metric-name) - (make-histogram-metric - registry - namespaced-metric-name))) - (start-time (current-time))) - (let ((result (thunk))) - (metric-observe metric (- (current-time) start-time)) - result))) + (define registry (slot-ref datastore 'metrics-registry)) + + (if registry + (let* ((namespaced-metric-name + (string-append "guixbuildcoordinator_" metric-name)) + (metric + (or (metrics-registry-fetch-metric registry namespaced-metric-name) + (make-histogram-metric + registry + namespaced-metric-name))) + (start-time (current-time))) + (let ((result (thunk))) + (metric-observe metric (- (current-time) start-time)) + result)) + (thunk))) (define-method (datastore-find-agent (datastore <sqlite-datastore>) |