Add new package instrument: go-redis #1525
Open
+1,722
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ref #1053
This project currently does not support Redis, and this PR aims to support it.
Instrumentation for the library
github.com/go-redis/redis/v8
is quite difficult, primarily because some of the available instrument functions include input params of typeinterface{}
(this issue is also mentioned in #1209) like this:A possible solution (found to be unfeasible after attempting)
I want to get the type of these
interface{}
type input params, then try to retrieving the corresponding value based on that type. Thetype
field's position ofeface
is:The biggest issue with this solution is its high level of complexity, which will exceed the instruction limit of eBPF(100W) with error
program uprobe_process: load program: argument list too long: BPF program is too large. Processed 1000001 insn (4760 line(s) omitted)
The implementation is the closed PR #1522
Final selected solution
So I suppose we cannot directly start from the
interface{}
input parameters of instrument function. I decided to start with the RESP protocol. Redis cmds will be encoded to bytes stream(RESP), so I chose the instrument func:But the
bufio
uses write-back buffer strategy. It makes me cannot determine the boundaries of a valid RESP byte stream which is significant for redis pipelining mode with multiple cmds. So I pre-fetched the segments of command through func:I also added a example
httpRedis
to validate the new instrumentation.