-
-
Couldn't load subscription status.
- Fork 597
feat(logger): add slow query logging support #6725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Added logs for slow queries that exceed the configurable threshold (default 200ms). Slow queries are logged with 'slowQuery' namespace and highlighted with yellow metadata. closes mikro-orm#4695
a604e3a to
8c75e78
Compare
8c75e78 to
8a83bee
Compare
|
@B4nan - could i please get a review on this ? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6725 +/- ##
========================================
Coverage 99.74% 99.74%
========================================
Files 267 267
Lines 19755 19782 +27
Branches 4327 4679 +352
========================================
+ Hits 19704 19731 +27
Misses 51 51 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
thanks! so how is this supposed to work in production when logs are disabled? we need a way to log stuff to the file system specifically for the slow query logs (regardless of how the default logging is set up), your PR only adds the new logger namespace. you can already set up a file logger but that means all logs would go there, maybe we could allow having multiple loggers, and set them up with different namespaces. slow query logging could be enabled automatically this way (logging to a txt file only the slow queries, regardless of the |
|
Oh! Okay, so we want the |
|
I am not sure if this should be enabled by default, but to me this is a production feature, and in production you don't usually enable query logging, since it would slow down the app and pollute the app logs like crazy. I'd say the best way to support this would be allowing multiple loggers, they can log to different places (console, file, some 3rd party service), based on different settings (log levels). Alternatively, only the slow query logs could be treated as a special case, but the former approach sounds cleaner. I haven't been thinking much about this, also not sure how it works in other ORMs, let's first agree on how this could look like before spending more time with implementation. |
closes #4695
slowQueryslowQueryThreshold[ Configurable ] - Default 200ms.slowQueryorqueryis added in debugMode options.This is my first contribution to Mikro ORM, i do not have a lot of experience with typescript either, i tried to do this while learning the same. So please feel free to let me know if i missed some nuances, i'm happy to address the feedback.