veepee-oss / Vp.FSharp.Sql

Generic F# ADO Provider Wrapper
https://github.com/veepee-oss/Vp.FSharp.Sql
ISC License
35 stars 3 forks source link

Expose query metrics? #29

Open absolutejam opened 1 year ago

absolutejam commented 1 year ago

Howdy!

I was curious whether this library or any of the underlying ADO providers provide any metrics around queries that they handle. I mostly opened this for discussion, and to see how feasible it is to get metrics from each provider, or if it's out of scope for this library.

I noticed that this library's queryAsyncSeq leverages Stopwatchs for tracking duration and uses this to log information. I wonder if there's any scope for exposing this information in the consumer-facing API (eg. toAsyncSeqWithMetrics). And then there's the decision on what metrics to expose; how to expose them; if this is feasible for each function (queryAsyncSeq vs queryListSync); and if it's feasible for each provider (SQL Server vs. Postgres).

I checked if Npgsql provides any out-the-box metrics for queries, but it doesn't seem to (it only produces aggregated metrics), and I don't really want to have to instrument my actual query if I can avoid it.

My current solution is to just a wrapper function that tracks the duration of the async with a Stopwatch. This is fine, but more detailed metrics would be nice for use when profiling queries - if this is even possible at this level of abstraction.

Cheers!