sqlx::query
tracing event - avoid string parsing for subscribers
#2671
Labels
enhancement
New feature or request
I built a custom tracing Layer which intercepts
sqlx::query
events in order to gather some query performance statistics across Spans.It's great that this event exists due to #2185 and the data is super useful, so thanks for that!
However while the layer, I noticed that due to all the integer fields and the
elapsed
timestamp being emitted asDebug
data, it causes some unnecessary parsing work on the subscriber which could potentially be avoided.For reference: Here's the code that I use to read the submitted data back into my
Layer
:As seen, the
elapsed
,rows_affected
androws_returned
fields are all emitted asdyn Debug
- which means a consumer can only handle them by printing those fields and parsing them again.tracing
unfortunately neither supportsu64
nortime::Duration
, so switching to those is not anOption
.A change would make the data cheaper to consume it moving towards
i64
for therows_
field and eg. something alongelapsed_us
which logs a plaini64
number for the elapsed time.Changing the format for an existing field would however be a backward incompatible change. So either new fields would need to be added in addition to the existing ones or such a change could be performed with a new major version.
Since parsing a
Duration
in a fairly undefined string format is probably the biggest pain point right now, the biggest improvement would be to addelapsed_us
in addition toelapsed
. The changes torows_
fields seem like something that could be done on the next major version change.The text was updated successfully, but these errors were encountered: