@@ -2,23 +2,22 @@ package status
22
33import (
44 "encoding/json"
5+ "log/slog"
56 "net/http"
67 "sync/atomic"
7-
8- "go.uber.org/zap"
98)
109
1110// readiness Handler return 200OK if all Plugins are ready to serve
1211// if one of the Plugins returns status from the 5xx range, the status for all queries will be 503
1312
1413type Ready struct {
15- log * zap .Logger
14+ log * slog .Logger
1615 unavailableStatusCode int
1716 statusRegistry map [string ]Readiness
1817 shutdownInitiated * atomic.Pointer [bool ]
1918}
2019
21- func NewReadyHandler (sr map [string ]Readiness , shutdownInitiated * atomic.Pointer [bool ], log * zap .Logger , usc int ) * Ready {
20+ func NewReadyHandler (sr map [string ]Readiness , shutdownInitiated * atomic.Pointer [bool ], log * slog .Logger , usc int ) * Ready {
2221 return & Ready {
2322 log : log ,
2423 statusRegistry : sr ,
@@ -47,7 +46,7 @@ func (rd *Ready) ServeHTTP(w http.ResponseWriter, r *http.Request) {
4746 StatusCode : http .StatusNotFound ,
4847 })
4948
50- rd .log .Info ("plugin is nil or not initialized" , zap . String ( "plugin" , k ) )
49+ rd .log .Info ("plugin is nil or not initialized" , "plugin" , k )
5150 continue
5251 }
5352
@@ -98,14 +97,14 @@ func (rd *Ready) ServeHTTP(w http.ResponseWriter, r *http.Request) {
9897 data , err := json .Marshal (report )
9998 if err != nil {
10099 // TODO do we need to write this error to the ResponseWriter?
101- rd .log .Error ("failed to marshal response" , zap . Error ( err ) )
100+ rd .log .Error ("failed to marshal response" , "error" , err )
102101 return
103102 }
104103
105104 // write the response
106105 _ , err = w .Write (data )
107106 if err != nil {
108- rd .log .Error ("failed to write response" , zap . Error ( err ) )
107+ rd .log .Error ("failed to write response" , "error" , err )
109108 }
110109
111110 return
@@ -160,18 +159,18 @@ func (rd *Ready) ServeHTTP(w http.ResponseWriter, r *http.Request) {
160159 })
161160 }
162161 } else {
163- rd .log .Info ("plugin does not support readiness checks" , zap . String ( "plugin" , plg [i ]) )
162+ rd .log .Info ("plugin does not support readiness checks" , "plugin" , plg [i ])
164163 }
165164 }
166165
167166 data , err := json .Marshal (report )
168167 if err != nil {
169- rd .log .Error ("failed to marshal response" , zap . Error ( err ) )
168+ rd .log .Error ("failed to marshal response" , "error" , err )
170169 }
171170
172171 // write the response
173172 _ , err = w .Write (data )
174173 if err != nil {
175- rd .log .Error ("failed to write response" , zap . Error ( err ) )
174+ rd .log .Error ("failed to write response" , "error" , err )
176175 }
177176}
0 commit comments