diff --git a/changelog.md b/changelog.md index 68c2b50f6f..9c482d64f9 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,10 @@ ## Unreleased +### Features + +* [3235](https://github.com/zeta-chain/node/pull/3235) - add /systemtime telemetry endpoint (zetaclient) + ### Tests * [3205](https://github.com/zeta-chain/node/issues/3205) - move Bitcoin revert address test to advanced group to avoid upgrade test failure diff --git a/zetaclient/metrics/telemetry.go b/zetaclient/metrics/telemetry.go index 7c50e9f248..c78bcd565d 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(systemTimeHandler)).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)) } +// systemTimeHandler returns the current system time in seconds +func systemTimeHandler(w http.ResponseWriter, _ *http.Request) { + nowString := time.Now().UTC().Format(time.RFC3339) + fmt.Fprintf(w, "%s", nowString) +} + // logMiddleware logs the incoming HTTP request func logMiddleware() mux.MiddlewareFunc { return func(handler http.Handler) http.Handler {