Skip to content

Replace internal tracing hooks with otelsql

Warren Gifford requested to merge devx/xp/otelsql into main

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.
  • sqlhooks probably needs to be patched, as it's missing one of the few optional methods and using it with otelsql.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:

CleanShot 2022-08-23 at 17 21 44@2x

Merge request reports

Loading