Skip to content

Commit

Permalink
feat(zetaclient): add /systemtime telemetry endpoint (#3235)
Browse files Browse the repository at this point in the history
* feat(zetaclient): add /systemtime telemetry endpoint

* fixes

* changelog
  • Loading branch information
gartnera authored Dec 3, 2024
1 parent f10ae08 commit 30924dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions zetaclient/metrics/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 30924dc

Please sign in to comment.