Replace internal tracing hooks with otelsql
Created by: jhchabran
Replace our in-house tracing for sql integration so it uses otelsql
instead. We're getting more details and tracing on the driver level.
Notes:
- I had to patch the library, as it caches too eagerly the trace provider, which result in never having it available in time as we always start the db before the rest in our
main()
functions. - I also made a patch to the library so keep feature parity, i.e have the query arguments added as attributes on the span itself.
- See https://github.com/sourcegraph/otelsql/pull/2
- The arguments are now added as
db.args.$n: value
.
-
sqlhooks
probably needs to be patched, as it's missing one of the few optional methods and using it withotelsql.Open
yields some issues. That being said it's highly probable that we end up not needing it at all because otelsql would handle everything.- Fixed by wrapping the driver.
- Once we have looked at the metrics being exported, we may possibly remove entirely the sqlhooks. For the time being, it's a good first iteration as it is (though it comes with a bit a juggling around interfaces).
Test plan
Tested locally, see https://github.com/sourcegraph/sourcegraph/issues/37905#issuecomment-1192557027
Update: added the arguments as attributes: