hedis icon indicating copy to clipboard operation
hedis copied to clipboard

Introducing hooks

Open kakkun61 opened this issue 1 year ago • 2 comments
trafficstars

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

  • ConnectInfo has a new field connectHooks
  • Hooks type is introduced

Currently there are five types of hooks:

  • sendRequest
  • sendPubSub
  • callback
  • send
  • receive

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 avatar Mar 19 '24 08:03 kakkun61

@informatikr How about this? 🤔

kakkun61 avatar Apr 02 '24 02:04 kakkun61

@aravindgopall How about this?

kakkun61 avatar Aug 02 '24 04:08 kakkun61