Skip to content

fix: register instrumented driver per-connection instead of per-driver-type#869

Open
lihan3238 wants to merge 1 commit intogobuffalo:mainfrom
lihan3238:fix-725
Open

fix: register instrumented driver per-connection instead of per-driver-type#869
lihan3238 wants to merge 1 commit intogobuffalo:mainfrom
lihan3238:fix-725

Conversation

@lihan3238
Copy link
Copy Markdown

Fixes #725

Summary

  • Replace sql.Register + sql.Open with sql.OpenDB using a per-connection driverConnector
  • Each connection now gets its own wrapped driver with its own InstrumentedDriverOptions
  • Previously, all connections sharing the same driver type (e.g., postgres) would use the first connections options

Context

The old code registered instrumented drivers globally per driver type (e.g., instrumented-sql-driver-postgres). When two connections used the same driver type with different instrumentation options, only the first connections options were applied. This fix creates a per-connection wrapped driver instead.

Test plan

  • gofmt passes on changed file
  • CI builds and tests pass (could not run locally due to Go module proxy timeout in WSL)

…r-type

Previously, instrumentDriver() used sql.Register() with a driver name
based on the driver type (e.g. instrumented-sql-driver-postgres). This
meant that multiple connections using the same driver type but different
instrumentation options would all share the first connection options.

Replace sql.Register + sql.Open with sql.OpenDB using a per-connection
driverConnector, so each connection gets its own wrapped driver with
its own options.

Fixes gobuffalo#725
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

instrumentDriver() register wrapped driver per driver instead of per connection

1 participant