Pull the metrics registry out of the controller
This will allow for instrumenting low level database functionality, before anything starts using the database.
This commit is contained in:
parent
7b69611755
commit
926cb2a5e1
2 changed files with 24 additions and 13 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
;;; Guix Data Service -- Information about Guix over time
|
;;; Guix Data Service -- Information about Guix over time
|
||||||
;;; Copyright © 2016, 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
|
;;; Copyright © 2016, 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
|
||||||
;;; Copyright © 2019 Christopher Baines <mail@cbaines.net>
|
;;; Copyright © 2019, 2020, 2021, 2022, 2023 Christopher Baines <mail@cbaines.net>
|
||||||
;;;
|
;;;
|
||||||
;;; This program is free software: you can redistribute it and/or
|
;;; This program is free software: you can redistribute it and/or
|
||||||
;;; modify it under the terms of the GNU Affero General Public License
|
;;; modify it under the terms of the GNU Affero General Public License
|
||||||
|
|
@ -72,6 +72,7 @@
|
||||||
#:use-module (guix-data-service web package controller)
|
#:use-module (guix-data-service web package controller)
|
||||||
#:export (%show-error-details
|
#:export (%show-error-details
|
||||||
handle-static-assets
|
handle-static-assets
|
||||||
|
make-render-metrics
|
||||||
controller))
|
controller))
|
||||||
|
|
||||||
(define cache-control-default-max-age
|
(define cache-control-default-max-age
|
||||||
|
|
@ -87,11 +88,8 @@
|
||||||
target
|
target
|
||||||
(list functions ...)))
|
(list functions ...)))
|
||||||
|
|
||||||
(define render-metrics
|
(define (make-render-metrics registry)
|
||||||
(let* ((registry (make-metrics-registry
|
(let* ((revisions-count-metric (make-gauge-metric registry
|
||||||
#:namespace "guixdataservice"))
|
|
||||||
|
|
||||||
(revisions-count-metric (make-gauge-metric registry
|
|
||||||
"revision_count"))
|
"revision_count"))
|
||||||
|
|
||||||
(load-new-guix-revision-job-count (make-gauge-metric
|
(load-new-guix-revision-job-count (make-gauge-metric
|
||||||
|
|
@ -558,13 +556,15 @@
|
||||||
(define* (controller request method-and-path-components
|
(define* (controller request method-and-path-components
|
||||||
mime-types body
|
mime-types body
|
||||||
secret-key-base
|
secret-key-base
|
||||||
startup-completed?)
|
startup-completed?
|
||||||
|
render-metrics)
|
||||||
(define (running-controller-thunk)
|
(define (running-controller-thunk)
|
||||||
(actual-controller request
|
(actual-controller request
|
||||||
method-and-path-components
|
method-and-path-components
|
||||||
mime-types
|
mime-types
|
||||||
body
|
body
|
||||||
secret-key-base))
|
secret-key-base
|
||||||
|
render-metrics))
|
||||||
|
|
||||||
(define (startup-controller-thunk)
|
(define (startup-controller-thunk)
|
||||||
(or
|
(or
|
||||||
|
|
@ -630,7 +630,8 @@
|
||||||
method-and-path-components
|
method-and-path-components
|
||||||
mime-types
|
mime-types
|
||||||
body
|
body
|
||||||
secret-key-base)
|
secret-key-base
|
||||||
|
render-metrics)
|
||||||
(define path
|
(define path
|
||||||
(uri-path (request-uri request)))
|
(uri-path (request-uri request)))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
;;; Guix Data Service -- Information about Guix over time
|
;;; Guix Data Service -- Information about Guix over time
|
||||||
;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
|
;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
|
||||||
;;; Copyright © 2019 Christopher Baines <mail@cbaines.net>
|
;;; Copyright © 2019, 2020, 2022, 2023 Christopher Baines <mail@cbaines.net>
|
||||||
;;;
|
;;;
|
||||||
;;; This program is free software: you can redistribute it and/or
|
;;; This program is free software: you can redistribute it and/or
|
||||||
;;; modify it under the terms of the GNU Affero General Public License
|
;;; modify it under the terms of the GNU Affero General Public License
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#:use-module (system repl error-handling)
|
#:use-module (system repl error-handling)
|
||||||
#:use-module (ice-9 atomic)
|
#:use-module (ice-9 atomic)
|
||||||
#:use-module (fibers web server)
|
#:use-module (fibers web server)
|
||||||
|
#:use-module (prometheus)
|
||||||
#:use-module (guix-data-service web controller)
|
#:use-module (guix-data-service web controller)
|
||||||
#:use-module (guix-data-service web util)
|
#:use-module (guix-data-service web util)
|
||||||
#:export (start-guix-data-service-web-server))
|
#:export (start-guix-data-service-web-server))
|
||||||
|
|
@ -39,7 +40,8 @@
|
||||||
#t)
|
#t)
|
||||||
#f))
|
#f))
|
||||||
|
|
||||||
(define (handler request body controller secret-key-base startup-completed)
|
(define (handler request body controller secret-key-base startup-completed
|
||||||
|
render-metrics)
|
||||||
(display
|
(display
|
||||||
(format #f "~a ~a\n"
|
(format #f "~a ~a\n"
|
||||||
(request-method request)
|
(request-method request)
|
||||||
|
|
@ -53,16 +55,24 @@
|
||||||
mime-types
|
mime-types
|
||||||
body
|
body
|
||||||
secret-key-base
|
secret-key-base
|
||||||
(check-startup-completed startup-completed)))))
|
(check-startup-completed startup-completed)
|
||||||
|
render-metrics))))
|
||||||
|
|
||||||
(define* (start-guix-data-service-web-server port host secret-key-base
|
(define* (start-guix-data-service-web-server port host secret-key-base
|
||||||
startup-completed)
|
startup-completed)
|
||||||
|
(define registry
|
||||||
|
(make-metrics-registry #:namespace "guixdataservice"))
|
||||||
|
|
||||||
|
(define render-metrics
|
||||||
|
(make-render-metrics registry))
|
||||||
|
|
||||||
(call-with-error-handling
|
(call-with-error-handling
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(run-server (lambda (request body)
|
(run-server (lambda (request body)
|
||||||
(handler request body controller
|
(handler request body controller
|
||||||
secret-key-base
|
secret-key-base
|
||||||
startup-completed))
|
startup-completed
|
||||||
|
render-metrics))
|
||||||
#:host host
|
#:host host
|
||||||
#:port port))
|
#:port port))
|
||||||
#:on-error 'backtrace
|
#:on-error 'backtrace
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue