MCPcopy
hub / github.com/redis/go-redis / PostHook

Method PostHook

maintnotifications/example_hooks.go:57–73  ·  maintnotifications/example_hooks.go::MetricsHook.PostHook

PostHook records processing completion and any errors.

(ctx context.Context, notificationCtx push.NotificationHandlerContext, notificationType string, notification []interface{}, result error)

Source from the content-addressed store, hash-verified

55
56// PostHook records processing completion and any errors.
57func (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.
76func (mh *MetricsHook) GetMetrics() map[string]interface{} {

Callers

nothing calls this directly

Calls 4

MetricsHookRecordedErrorFunction · 0.92
GetIDMethod · 0.80
ValueMethod · 0.65
PrintfMethod · 0.65

Tested by

no test coverage detected