hugsql

rgm 2021-12-23T18:23:23.028100Z

does anyone have any experience instrumenting hugsql? I want to throw some timings for SQL calls into statsd and I'm considering hacking up my own wrapper around def-db-fns, so that I don't need to add a timing wrapper around every call site.

lukasz 2021-12-23T18:40:27.028200Z

Usually drivers and/or connection pools help with that - e.g. hikaricp accepts a metric registry, it's based on Dropwizard metrics so it should be pretty flexible

rgm 2021-12-23T18:42:36.028400Z

oh right, yeah, thanks ... working at the level of the pool or the adapter probably makes more sense for timings and counts.

rgm 2021-12-23T18:42:42.028600Z

Might have to come back to this idea for doing traces & the execution hierarchy since that's not going to be just hugsql.

lukasz 2021-12-23T18:45:21.028800Z

You can also turn the problem on its head and have slow query log setup in your database - a bit harder to tie it to the code, but requires no changes in your app

rgm 2021-12-23T18:46:44.029Z

true ... unfortunately using a postgres appliance at DO so a bit limited in how much messing around with config I can do. Suppose there's a bunch that can be done from a psql session though.

lukasz 2021-12-23T18:47:47.029200Z

Ah that's true - I'm spoiled with RDS, and even though it is a managed service, it does expose enough useful info to see what's going on

rgm 2021-12-23T18:49:00.029400Z

yeah, true. DO improves day by day and honestly most of the time it's probably better I can't disappear down a tuning rabbit hole