@@ -144,8 +144,9 @@ func (h *messageHandler) Handle(ctx context.Context, msg *mqs.Message) error {
144144 }
145145
146146 h .logger .Ctx (ctx ).Info ("processing delivery event" ,
147- zap .String ("delivery_event_id" , deliveryEvent .ID ),
148147 zap .String ("event_id" , deliveryEvent .Event .ID ),
148+ zap .String ("tenant_id" , deliveryEvent .Event .TenantID ),
149+ zap .String ("destination_id" , deliveryEvent .DestinationID ),
149150 zap .Int ("attempt" , deliveryEvent .Attempt ))
150151
151152 // Ensure event data
@@ -198,8 +199,10 @@ func (h *messageHandler) doHandle(ctx context.Context, deliveryEvent models.Deli
198199
199200 h .logger .Ctx (ctx ).Error ("failed to publish event" ,
200201 zap .Error (err ),
201- zap .String ("delivery_event_id" , deliveryEvent .ID ),
202- zap .String ("destination_id" , destination .ID ))
202+ zap .String ("event_id" , deliveryEvent .Event .ID ),
203+ zap .String ("tenant_id" , deliveryEvent .Event .TenantID ),
204+ zap .String ("destination_id" , destination .ID ),
205+ zap .String ("destination_type" , destination .Type ))
203206 deliveryErr := & DeliveryError {err : err }
204207
205208 if h .shouldScheduleRetry (deliveryEvent , err ) {
@@ -216,12 +219,18 @@ func (h *messageHandler) doHandle(ctx context.Context, deliveryEvent models.Deli
216219 if err := h .retryScheduler .Cancel (ctx , deliveryEvent .GetRetryID ()); err != nil {
217220 h .logger .Ctx (ctx ).Error ("failed to cancel scheduled retry" ,
218221 zap .Error (err ),
219- zap .String ("delivery_event_id" , deliveryEvent .ID ),
222+ zap .String ("event_id" , deliveryEvent .Event .ID ),
223+ zap .String ("tenant_id" , deliveryEvent .Event .TenantID ),
224+ zap .String ("destination_id" , destination .ID ),
225+ zap .String ("destination_type" , destination .Type ),
220226 zap .String ("retry_id" , deliveryEvent .GetRetryID ()))
221227 return h .logDeliveryResult (ctx , & deliveryEvent , destination , delivery , err )
222228 }
223229 logger .Audit ("scheduled retry canceled" ,
224- zap .String ("delivery_event_id" , deliveryEvent .ID ),
230+ zap .String ("event_id" , deliveryEvent .Event .ID ),
231+ zap .String ("tenant_id" , deliveryEvent .Event .TenantID ),
232+ zap .String ("destination_id" , destination .ID ),
233+ zap .String ("destination_type" , destination .Type ),
225234 zap .String ("retry_id" , deliveryEvent .GetRetryID ()))
226235 }
227236 return h .logDeliveryResult (ctx , & deliveryEvent , destination , delivery , nil )
@@ -234,19 +243,22 @@ func (h *messageHandler) logDeliveryResult(ctx context.Context, deliveryEvent *m
234243 deliveryEvent .Delivery = delivery
235244
236245 logger .Audit ("event delivered" ,
237- zap .String ("delivery_event_id" , deliveryEvent .ID ),
238- zap .String ("destination_id" , deliveryEvent .DestinationID ),
239246 zap .String ("event_id" , deliveryEvent .Event .ID ),
247+ zap .String ("tenant_id" , deliveryEvent .Event .TenantID ),
248+ zap .String ("destination_id" , destination .ID ),
249+ zap .String ("destination_type" , destination .Type ),
240250 zap .String ("delivery_status" , deliveryEvent .Delivery .Status ),
241251 zap .Int ("attempt" , deliveryEvent .Attempt ),
242- zap .Bool ("manual" , deliveryEvent .Manual ),
243- zap .String ("destination_type" , destination .Type ))
252+ zap .Bool ("manual" , deliveryEvent .Manual ))
244253
245254 // Publish delivery log
246255 if logErr := h .logMQ .Publish (ctx , * deliveryEvent ); logErr != nil {
247256 logger .Error ("failed to publish delivery log" ,
248257 zap .Error (logErr ),
249- zap .String ("delivery_event_id" , deliveryEvent .ID ))
258+ zap .String ("event_id" , deliveryEvent .Event .ID ),
259+ zap .String ("tenant_id" , deliveryEvent .Event .TenantID ),
260+ zap .String ("destination_id" , destination .ID ),
261+ zap .String ("destination_type" , destination .Type ))
250262 if err != nil {
251263 return & PostDeliveryError {err : errors .Join (err , logErr )}
252264 }
@@ -315,14 +327,18 @@ func (h *messageHandler) handleAlertAttempt(ctx context.Context, deliveryEvent *
315327 if monitorErr := h .alertMonitor .HandleAttempt (ctx , attempt ); monitorErr != nil {
316328 h .logger .Ctx (ctx ).Error ("failed to handle alert attempt" ,
317329 zap .Error (monitorErr ),
318- zap .String ("delivery_event_id" , deliveryEvent .ID ),
319- zap .String ("destination_id" , destination .ID ))
330+ zap .String ("event_id" , deliveryEvent .Event .ID ),
331+ zap .String ("tenant_id" , destination .TenantID ),
332+ zap .String ("destination_id" , destination .ID ),
333+ zap .String ("destination_type" , destination .Type ))
320334 return
321335 }
322336
323337 h .logger .Ctx (ctx ).Info ("alert attempt handled" ,
324- zap .String ("delivery_event_id" , deliveryEvent .ID ),
325- zap .String ("destination_id" , destination .ID ))
338+ zap .String ("event_id" , deliveryEvent .Event .ID ),
339+ zap .String ("tenant_id" , destination .TenantID ),
340+ zap .String ("destination_id" , destination .ID ),
341+ zap .String ("destination_type" , destination .Type ))
326342}
327343
328344func (h * messageHandler ) shouldScheduleRetry (deliveryEvent models.DeliveryEvent , err error ) bool {
@@ -395,14 +411,18 @@ func (h *messageHandler) scheduleRetry(ctx context.Context, deliveryEvent models
395411 if err := h .retryScheduler .Schedule (ctx , retryMessageStr , backoffDuration , scheduler .WithTaskID (deliveryEvent .GetRetryID ())); err != nil {
396412 h .logger .Ctx (ctx ).Error ("failed to schedule retry" ,
397413 zap .Error (err ),
398- zap .String ("delivery_event_id" , deliveryEvent .ID ),
414+ zap .String ("event_id" , deliveryEvent .Event .ID ),
415+ zap .String ("tenant_id" , deliveryEvent .Event .TenantID ),
416+ zap .String ("destination_id" , deliveryEvent .DestinationID ),
399417 zap .Int ("attempt" , deliveryEvent .Attempt ),
400418 zap .Duration ("backoff" , backoffDuration ))
401419 return err
402420 }
403421
404422 h .logger .Ctx (ctx ).Audit ("retry scheduled" ,
405- zap .String ("delivery_event_id" , deliveryEvent .ID ),
423+ zap .String ("event_id" , deliveryEvent .Event .ID ),
424+ zap .String ("tenant_id" , deliveryEvent .Event .TenantID ),
425+ zap .String ("destination_id" , deliveryEvent .DestinationID ),
406426 zap .Int ("attempt" , deliveryEvent .Attempt ),
407427 zap .Duration ("backoff" , backoffDuration ))
408428
@@ -438,8 +458,9 @@ func (h *messageHandler) ensurePublishableDestination(ctx context.Context, deliv
438458 logger := h .logger .Ctx (ctx )
439459 fields := []zap.Field {
440460 zap .Error (err ),
441- zap .String ("destination_id " , deliveryEvent .DestinationID ),
461+ zap .String ("event_id " , deliveryEvent .Event . ID ),
442462 zap .String ("tenant_id" , deliveryEvent .Event .TenantID ),
463+ zap .String ("destination_id" , deliveryEvent .DestinationID ),
443464 }
444465
445466 if errors .Is (err , models .ErrDestinationDeleted ) {
@@ -452,12 +473,15 @@ func (h *messageHandler) ensurePublishableDestination(ctx context.Context, deliv
452473 }
453474 if destination == nil {
454475 h .logger .Ctx (ctx ).Info ("destination not found" ,
455- zap .String ("destination_id" , deliveryEvent .DestinationID ),
456- zap .String ("tenant_id" , deliveryEvent .Event .TenantID ))
476+ zap .String ("event_id" , deliveryEvent .Event .ID ),
477+ zap .String ("tenant_id" , deliveryEvent .Event .TenantID ),
478+ zap .String ("destination_id" , deliveryEvent .DestinationID ))
457479 return nil , models .ErrDestinationNotFound
458480 }
459481 if destination .DisabledAt != nil {
460482 h .logger .Ctx (ctx ).Info ("skipping disabled destination" ,
483+ zap .String ("event_id" , deliveryEvent .Event .ID ),
484+ zap .String ("tenant_id" , deliveryEvent .Event .TenantID ),
461485 zap .String ("destination_id" , destination .ID ),
462486 zap .String ("destination_type" , destination .Type ),
463487 zap .Time ("disabled_at" , * destination .DisabledAt ))
0 commit comments