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
The function instrumentDriver() registers a custom SQL driver with sql.Register() and it uses a decorated driver name as something like instrumented-sql-driver-sqlite3 which is based on the driver name but actually it used wrapper options per connection. So if there are two or more connections with the same driver, only one wrapped driver will be registered with the wrapper option of the first successful connection.
The purpose of the wrapped driver is to support logging, tracing, etc. and those actions can be applied to each connection with different settings.
I guess one option to consider would be to not register the instrumented drivers in the first place. After looking a bit through the code, it would be easily possible to just not register them. There is only two usages of sql.Open:
which is the single point of opening a driver in the first place
Instead of using sql.Open, it would be possible to just get the driver, potentially wrap it, and then use sql.OpenDB instead (essentially re-implement what sql.Open does, with the driver as a parameter).
The function
instrumentDriver()
registers a custom SQL driver withsql.Register()
and it uses a decorated driver name as something likeinstrumented-sql-driver-sqlite3
which is based on the driver name but actually it used wrapper options per connection. So if there are two or more connections with the same driver, only one wrapped driver will be registered with the wrapper option of the first successful connection.The purpose of the wrapped driver is to support logging, tracing, etc. and those actions can be applied to each connection with different settings.
pop/connection_instrumented.go
Line 17 in d146f1b
See this and the following comments for more details.
Related Issues or PRs
The text was updated successfully, but these errors were encountered: