-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add WithDBStatement to add db.statement attribute to rueidisotel #523
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #523 +/- ##
==========================================
- Coverage 95.57% 95.53% -0.05%
==========================================
Files 80 80
Lines 33178 33204 +26
==========================================
+ Hits 31710 31721 +11
- Misses 1267 1278 +11
- Partials 201 205 +4 ☔ View full report in Codecov by Sentry. |
Hi @chkp-omris, Unlike other database systems, capturing the full redis command into Could you just capture at most two tokens from a command? For example, the |
@rueian thanks for the quick response. I think it's reasonable to have the same limitation in |
32 bytes capping is good, but I think we should also take only the first two tokens to avoid capturing any credentials. |
@rueian First of all I hope you and your loved ones are safe after the earthquake in Taiwan.
It depends on the user's use case. Also, I suggest applying the 32 bytes cap to each token in the command, as there could be flags/options given that are important. Let me know what you think and I'll implement it. |
Thank you! We are fine.
So, instead of In this way, users have full responsibility for the statement being sent. |
…mand's tokens to the string of db.statement
Yea that's a good idea, done |
@@ -83,6 +99,10 @@ func (o *otelclient) DoMulti(ctx context.Context, multi ...rueidis.Completed) (r | |||
|
|||
func (o *otelclient) DoStream(ctx context.Context, cmd rueidis.Completed) (resp rueidis.RedisResultStream) { | |||
ctx, span := o.start(ctx, first(cmd.Commands()), sum(cmd.Commands()), o.tAttrs) | |||
if o.dbStmtFunc != nil { | |||
span.SetAttributes(dbstmt.String(o.dbStmtFunc(cmd.Commands()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @chkp-omris, LGTM! But these SetAttributes are not covered by tests

Would you mind to add tests for them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rueian Sure, I added the option to the unit tests for the client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Add tracer option to add the whole command's statement to db.statement attribute.
Need this for integration with APM and couldn't find another way that doesn't involve copying a lot of code from
otelClient
's implementation.I mostly use non-multi operations and they seem a bit more complex and opinionated so I didn't implement it on my own.