You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to add a config option to skip the tx.Dialector.Explainstep step when tracing the query (i.e. just record the result of tx.Statement.SQL.String()). This can either be its own option or it could replace the WithoutQueryVariables() option, which has some significant performance issues for some uses (see below). I'm not sure that there's a good use case for WithoutQueryVariables() that wouldn't be solved with the proposed option.
If you're open to this request, I can open a PR for this change.
Motivation
I'm using this plugin in a production environment, configured with the WithoutQueryVariables() option. We originally configured the overall tracing with a relatively low sampling rate (10%) and there wasn't a noticeable change in performance. When we switch to 100% tracing (in order to tail sample our traces), we noticed a very large increase in latency and high CPU utilization that we traced back to the use of this plugin (by disabling it and re-testing).
We traced the actual performance issue to the use of tx.Dialector.Explain, which substitutes the actual parameters into the query string. This results in a lot of string copies, which I think makes sense given what it's doing. We use the WithoutQueryVariables() option, but all that does is substitute ? for the variable values -- it still does the string interpolation.
My preliminary performance testing of the forked version mentioned above shows that the high CPU utilization and latency goes away but we still get a useful representation of the SQL query used.
Related Issues
The text was updated successfully, but these errors were encountered:
@chradcliffe Pull Requests are highly welcome. In some scenarios, specific query parameters are also required, so I think the current approach of using options for modification is very appropriate.
Describe the feature
I'd like to add a config option to skip the
tx.Dialector.Explain
step step when tracing the query (i.e. just record the result oftx.Statement.SQL.String()
). This can either be its own option or it could replace theWithoutQueryVariables()
option, which has some significant performance issues for some uses (see below). I'm not sure that there's a good use case forWithoutQueryVariables()
that wouldn't be solved with the proposed option.I have a working version of the option in a fork I created here: master...tonalfitness:gorm-opentelemetry:master
If you're open to this request, I can open a PR for this change.
Motivation
I'm using this plugin in a production environment, configured with the
WithoutQueryVariables()
option. We originally configured the overall tracing with a relatively low sampling rate (10%) and there wasn't a noticeable change in performance. When we switch to 100% tracing (in order to tail sample our traces), we noticed a very large increase in latency and high CPU utilization that we traced back to the use of this plugin (by disabling it and re-testing).We traced the actual performance issue to the use of
tx.Dialector.Explain
, which substitutes the actual parameters into the query string. This results in a lot of string copies, which I think makes sense given what it's doing. We use theWithoutQueryVariables()
option, but all that does is substitute?
for the variable values -- it still does the string interpolation.My preliminary performance testing of the forked version mentioned above shows that the high CPU utilization and latency goes away but we still get a useful representation of the SQL query used.
Related Issues
The text was updated successfully, but these errors were encountered: