On Mon, 2018-09-10 at 09:05 +0100, Tristan Colgate wrote: > There are two existing projects used to achieve similar goals: > > https://github.com/ExpansiveWorlds/instrumentedsql > https://github.com/gchaincl/sqlhooks > > native support could probably improve things a little, but this is a > very reasonable approach.
tldr; It's definitely a valid approach - I still think it is benefitial to include in sql core package. In my view, there are two benefits to adding it to the main sql package compared to wrapping a driver: 1) It makes it very simple, and thus encourages, the monitoring of sql queries, which I think is a good addition to the core golang libraries. 2) The interceptor can be added/removed at runtime. Of course, this could also be done with a driver-wrapper, but not quite as elegantly and IMHO with more potential to subtle race-conditions. 3) gRPC already has such mechanism (which is very useful) and being in- line and consistent with another package, namely gRPC, makes life easier for golang developers.(SQL Queries to a database are in my view similar to RPC calls, since both call external systems), 4) we can encourage 3rd parties to add interceptors to their products. For example: I like to see a hook to expose metrics to prometheus. currently the default client exposes useful golang core metrics (e.g. "go_gc_duration_seconds"). Adding it to core language (and applying the compatibility guarantees) is likely to increase uptake and we all benefit. Thus I could submit a patch to prometheus and say "look, this exposes more core metrics" ;) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.