informatikr / hedis

A Redis client library for Haskell.
http://hackage.haskell.org/package/hedis
BSD 3-Clause "New" or "Revised" License
329 stars 127 forks source link

Introducing hooks #223

Closed kakkun61 closed 6 days ago

kakkun61 commented 8 months ago

This PR introduce hooks. These hooks hook sending requests and receiving responses.

Motivation

I am implementing an instrumentation of OpenTelemetry for Hedis. First I wrapped the Hedis functions to record for tracing, but it cause a lot of type mismatch because the original client and the wrappers have different types of course. So I want to use hooks to avoid this inconvenience.

Changes

Currently there are five types of hooks:

sendRequest is called when a command is being sent. sendPubSub is called when a Pub/Sub message is being send. callback is called when a reaction to a Pub/Sub message is being called after receiving its message. send and receive are low-level hooks

Notes

A WIP implementation of the instrumentation of OpenTelemetry for Hedis is https://github.com/herp-inc/hs-opentelemetry/pull/15/.

kakkun61 commented 8 months ago

@informatikr How about this? 🤔

kakkun61 commented 4 months ago

@aravindgopall How about this?

asheshambasta commented 1 week ago

What's holding this PR back?

aravindgopall commented 1 week ago

Apologies for late reply.

@kakkun61 can you add tests with hooks and also make sure the currents test suite is working fine. We will get this merged asap post that.

kakkun61 commented 1 week ago

@aravindgopall Thank you for review. OK.

kakkun61 commented 1 week ago

@aravindgopall I added a very simple test-suite hedis-test-hooks.