Skip to content

Commit

Permalink
feat(zetaclient): add /systemtime telemetry endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Dec 2, 2024
1 parent 08ff881 commit 56d2f08
Showing 1 changed file with 7 additions and 0 deletions.
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(systemdTimeHandler)).Methods(http.MethodGet)

Check warning on line 194 in zetaclient/metrics/telemetry.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/metrics/telemetry.go#L194

Added line #L194 was not covered by tests
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))
}

// 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))

Check failure on line 340 in zetaclient/metrics/telemetry.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary conversion (unconvert)

Check warning on line 340 in zetaclient/metrics/telemetry.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/metrics/telemetry.go#L338-L340

Added lines #L338 - L340 were not covered by tests
}

// logMiddleware logs the incoming HTTP request
func logMiddleware() mux.MiddlewareFunc {
return func(handler http.Handler) http.Handler {
Expand Down

0 comments on commit 56d2f08

Please sign in to comment.