PostHook records processing completion and any errors.
(ctx context.Context, notificationCtx push.NotificationHandlerContext, notificationType string, notification []interface{}, result error)
| 55 | |
| 56 | // PostHook records processing completion and any errors. |
| 57 | func (mh *MetricsHook) PostHook(ctx context.Context, notificationCtx push.NotificationHandlerContext, notificationType string, notification []interface{}, result error) { |
| 58 | // Calculate processing duration |
| 59 | if startTime, ok := ctx.Value(startTimeKey).(time.Time); ok { |
| 60 | duration := time.Since(startTime) |
| 61 | mh.ProcessingTimes[notificationType] = duration |
| 62 | } |
| 63 | |
| 64 | // Record errors |
| 65 | if result != nil { |
| 66 | mh.ErrorCounts[notificationType]++ |
| 67 | |
| 68 | // Log error details with connection information |
| 69 | if conn, ok := notificationCtx.Conn.(*pool.Conn); ok { |
| 70 | internal.Logger.Printf(ctx, logs.MetricsHookRecordedError(notificationType, conn.GetID(), result)) |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // GetMetrics returns a summary of collected metrics. |
| 76 | func (mh *MetricsHook) GetMetrics() map[string]interface{} { |
nothing calls this directly
no test coverage detected