@@ -34,11 +34,11 @@ func NewApplicationEventReporter(server *Server) *applicationEventReporter {
3434}
3535
3636func (s * applicationEventReporter ) shouldSendResourceEvent (a * appv1.Application , rs appv1.ResourceStatus ) bool {
37- logCtx := log .WithFields (log.Fields {
37+ logCtx := logWithResourceStatus ( log .WithFields (log.Fields {
3838 "app" : a .Name ,
3939 "gvk" : fmt .Sprintf ("%s/%s/%s" , rs .Group , rs .Version , rs .Kind ),
4040 "resource" : fmt .Sprintf ("%s/%s" , rs .Namespace , rs .Name ),
41- })
41+ }), rs )
4242
4343 cachedRes , err := s .server .cache .GetLastResourceEvent (a , rs , getApplicationLatestRevision (a ))
4444 if err != nil {
@@ -105,7 +105,7 @@ func (s *applicationEventReporter) streamApplicationEvents(
105105 ts string ,
106106) error {
107107 var (
108- logCtx = log .WithField ("application " , a .Name )
108+ logCtx = log .WithField ("app " , a .Name )
109109 )
110110
111111 logCtx .Info ("streaming application events" )
@@ -225,11 +225,11 @@ func (s *applicationEventReporter) processResource(
225225 if isApp (rs ) && actualState .Manifest != "" && json .Unmarshal ([]byte (actualState .Manifest ), & appRes ) == nil {
226226 logWithAppStatus (& appRes , logCtx , ts ).Info ("streaming resource event" )
227227 } else {
228- logCtx .Info ("streaming resource event" )
228+ logWithResourceStatus ( logCtx , rs ) .Info ("streaming resource event" )
229229 }
230230
231231 if err := stream .Send (ev ); err != nil {
232- logCtx .WithError (err ).Error ("failed to send even " )
232+ logCtx .WithError (err ).Error ("failed to send event " )
233233 return
234234 }
235235
@@ -239,7 +239,7 @@ func (s *applicationEventReporter) processResource(
239239}
240240
241241func (s * applicationEventReporter ) shouldSendApplicationEvent (ae * appv1.ApplicationWatchEvent ) bool {
242- logCtx := log .WithField ("application " , ae .Application .Name )
242+ logCtx := log .WithField ("app " , ae .Application .Name )
243243
244244 if ae .Type == watch .Deleted {
245245 logCtx .Info ("application deleted" )
@@ -284,10 +284,21 @@ func isApp(rs appv1.ResourceStatus) bool {
284284
285285func logWithAppStatus (a * appv1.Application , logCtx * log.Entry , ts string ) * log.Entry {
286286 return logCtx .WithFields (log.Fields {
287- "status" : a .Status .Sync .Status ,
287+ "sync" : a .Status .Sync .Status ,
288+ "health" : a .Status .Health .Status ,
288289 "resourceVersion" : a .ResourceVersion ,
289290 "ts" : ts ,
290291 })
292+
293+ }
294+
295+ func logWithResourceStatus (logCtx * log.Entry , rs appv1.ResourceStatus ) * log.Entry {
296+ logCtx = logCtx .WithField ("sync" , rs .Status )
297+ if rs .Health != nil {
298+ logCtx = logCtx .WithField ("health" , rs .Health .Status )
299+ }
300+
301+ return logCtx
291302}
292303
293304func getLatestAppHistoryItem (a * appv1.Application ) * appv1.RevisionHistory {
0 commit comments