aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator/datastore/sqlite.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix-build-coordinator/datastore/sqlite.scm')
-rw-r--r--guix-build-coordinator/datastore/sqlite.scm33
1 files changed, 19 insertions, 14 deletions
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm
index 974f538..ec52cb4 100644
--- a/guix-build-coordinator/datastore/sqlite.scm
+++ b/guix-build-coordinator/datastore/sqlite.scm
@@ -453,24 +453,29 @@ PRAGMA optimize;")
#t)
(define (call-with-time-tracking datastore thing thunk)
+ (let* ((start-time (get-internal-real-time)))
+ (call-with-values
+ thunk
+ (lambda vals
+ (metric-observe-duration
+ datastore
+ thing
+ (/ (- (get-internal-real-time) start-time)
+ internal-time-units-per-second))
+ (apply values vals)))))
+
+(define (metric-observe-duration datastore
+ thing
+ duration-seconds)
(define registry (slot-ref datastore 'metrics-registry))
(define metric-name
(string-append "datastore_" thing "_duration_seconds"))
- (if registry
- (let* ((metric
- (or (metrics-registry-fetch-metric registry metric-name)
- (make-histogram-metric registry
- metric-name)))
- (start-time (get-internal-real-time)))
- (call-with-values
- thunk
- (lambda vals
- (metric-observe metric
- (/ (- (get-internal-real-time) start-time)
- internal-time-units-per-second))
- (apply values vals))))
- (thunk)))
+ (let ((metric
+ (or (metrics-registry-fetch-metric registry metric-name)
+ (make-histogram-metric registry
+ metric-name))))
+ (metric-observe metric duration-seconds)))
(define (call-with-worker-thread/delay-logging channel proc)
(call-with-worker-thread channel