feat: Add tracing channels support #193
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds Node.js tracing channels for db query operations, enabling observability and performance monitoring.
Channel Naming Convention
All channels use the
db0.queryconvention which when coupled with tracing channels produce the following diagnostic channels:tracing:db0.query:starttracing:db0.query:endtracing:db0.query:asyncStarttracing:db0.query:asyncEndtracing:db0.query:errorWhich matches nicely with
fastifybut there isn't a lot of convention for them other than the Node.js recommendation.Unlike
unstorageit didn't feel like we need multiple channels since more or less it boils down to executing a query.Tracing context includes
query- query to be executedmethod- source of the query likesqlorexec, basically the method name.dialect- the db dialectExample
I have made it so it is opt-in like
unstorage.Users can create traced instances like so:
SDKs and consumers can then do:
All operations emit standard tracing events:
start,end,asyncStart,asyncEnd, anderror.