Skip to content

Conversation

jrmarkle
Copy link
Contributor

This could be used to update metrics or debug/logging (#259).

There are many ways this could be done. I chose a way that involves minimal changes.

Example usage:

    client = redis.NewClient(...)

    client.WrapProcess(func(oldProcess func(cmd redis.Cmder) error) func(cmd redis.Cmder) error {
        return func(cmd redis.Cmder) error {
            before := time.Now()

            err := oldProcess(cmd)

            if err != nil {
                log.Println(`error running redis command "`, cmd, `": `, err)
            } else {
                log.Println(`running redis command "`, cmd, `" took `, time.Since(before))
            }

            return err
        }
    })

@vmihailenco
Copy link
Collaborator

I like this - thanks!

@vmihailenco vmihailenco merged commit 909c26e into redis:v4 Aug 17, 2016
@vmihailenco
Copy link
Collaborator

Released in v4.1.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants