From be4490269d5e418f1c7cc08b7b6ca3f274b6742c Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Mon, 2 Dec 2024 15:42:08 -0800 Subject: [PATCH] feat(zetaclient): add /systemtime telemetry endpoint --- zetaclient/metrics/telemetry.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/zetaclient/metrics/telemetry.go b/zetaclient/metrics/telemetry.go index 7c50e9f248..a2eac3264a 100644 --- a/zetaclient/metrics/telemetry.go +++ b/zetaclient/metrics/telemetry.go @@ -191,6 +191,7 @@ func (t *TelemetryServer) Handlers() http.Handler { router.Handle("/connectedpeers", http.HandlerFunc(t.connectedPeersHandler)).Methods(http.MethodGet) router.Handle("/knownpeers", http.HandlerFunc(t.knownPeersHandler)).Methods(http.MethodGet) router.Handle("/pingrtt", http.HandlerFunc(t.pingRTTHandler)).Methods(http.MethodGet) + router.Handle("/systemtime", http.HandlerFunc(systemdTimeHandler)).Methods(http.MethodGet) router.Use(logMiddleware()) return router @@ -333,6 +334,12 @@ func (t *TelemetryServer) pingRTTHandler(w http.ResponseWriter, _ *http.Request) fmt.Fprintf(w, "%s", string(data)) } +// systemdTimeHandler returns the current system time in seconds +func systemdTimeHandler(w http.ResponseWriter, _ *http.Request) { + nowString := time.Now().UTC().Format(time.RFC3339) + fmt.Fprintf(w, "%s", string(nowString)) +} + // logMiddleware logs the incoming HTTP request func logMiddleware() mux.MiddlewareFunc { return func(handler http.Handler) http.Handler {