mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
Backend: Expose prometheus-style metrics endpoint
Expose a new API which can be scraped by prometheus to gather useful metrics from an instance. The new endpoint exposes photoprism build version information, golang version, edition and various count metrics.
This commit is contained in:
committed by
Michael Mayer
parent
0935d9fab0
commit
3d962e2382
@@ -15,6 +15,19 @@ import (
|
||||
"github.com/photoprism/photoprism/internal/get"
|
||||
)
|
||||
|
||||
type CloseableResponseRecorder struct {
|
||||
*httptest.ResponseRecorder
|
||||
closeCh chan bool
|
||||
}
|
||||
|
||||
func (r *CloseableResponseRecorder) CloseNotify() <-chan bool {
|
||||
return r.closeCh
|
||||
}
|
||||
|
||||
func (r *CloseableResponseRecorder) closeClient() {
|
||||
r.closeCh <- true
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
log = logrus.StandardLogger()
|
||||
log.SetLevel(logrus.TraceLevel)
|
||||
@@ -60,3 +73,13 @@ func PerformRequestWithBody(r http.Handler, method, path, body string) *httptest
|
||||
|
||||
return w
|
||||
}
|
||||
|
||||
// Executes an API request with a stream response.
|
||||
func PerformRequestWithStream(r http.Handler, method, path string) *CloseableResponseRecorder {
|
||||
req, _ := http.NewRequest(method, path, nil)
|
||||
w := &CloseableResponseRecorder{httptest.NewRecorder(), make(chan bool, 1)}
|
||||
|
||||
r.ServeHTTP(w, req)
|
||||
|
||||
return w
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user