Commit graph

66 commits

Author SHA1 Message Date
Ankush Menat
fa6dc03cc8
refactor: frappe.cache() usage to frappe.cache (#21282) 2023-06-08 11:47:17 +05:30
Ankush Menat
ec3f705e4f
feat: finer frappe Recorder control with decorator (#19220)
Currently frappe recorder can be enabled globally and profiles every
request. This is often way too much info. If you already know where
problem lies you use this decorator sparingly to only profile relevant
functions.

Usage:
```py
from frappe.recorder import record_queries

@record_queries
def sus_slow_function():
    frappe.db.sql("select everything from everywhere")
```
2022-12-09 14:18:49 +05:30
Ankush Menat
bbcc365a24
fix: use monotonic clock for timing code (#19138)
* fix: use monotonic time for timing code

`time.time()` depends on system clock which can drift away and get corrected
over time. If you're unlucky it will get corrected in your timing code
and give absurd results.

* test: dont check for status

can refresh and give wrong output

[skip ci]
2022-12-06 15:42:37 +05:30
Gavin D'souza
c86e1de38a fix(recorder): Publish update only to Administrator 2022-11-15 13:12:51 +05:30
Gavin D'souza
71b5c77e6e Merge branch 'develop' of github.com:frappe/frappe into mariadb-client-refactor 2022-07-05 14:55:02 +05:30
Ankush Menat
81b37cb7d2
refactor: clean up code to py310 supported features (#17367)
refactor: clean up code to py39+ supported syntax

- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes

Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
2022-07-01 11:51:05 +05:30
Gavin D'souza
bc3780560e perf: Use lazy mogrified query for logging
For parameterized queries, there's an improvement of ~30% in query
execution via frappe.db.sql - from 58.6 µs ± 2.37 µs to 44.6 µs ± 1.56 µs
2022-06-16 14:26:34 +05:30
Gavin D'souza
154d794c6c fix: Recorder to use frappe.db.last_query to pick out last executed stmt 2022-06-16 13:29:35 +05:30
Gavin D'souza
b696fa6da5 perf: Pre-compile and re-use regexp pattern
Converted all possible usages of re.* that weren't compiling the regex
separately and re-using it. Separated out the compiled patterns as
global variables. Repetitive patterns could be made DRY-er.

Would be nicer to have all regexes in a single module so that we could
re-use better, keep track of outdated, and keep checks for possible
reDos' etc
2022-06-08 14:07:38 +05:30
Suraj Shetty
c0c5b2ebdd
style: format all python files using black (#16453)
Co-authored-by: Frappe Bot <developers@frappe.io>
2022-04-12 10:59:25 +05:30
Gavin D'souza
3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30
Ankush Menat
1bebe28876
feat: import/export full recorder captures 2021-08-25 23:20:55 +05:30
Gavin D'souza
e407b78506 chore: Drop dead and deprecated code
* Remove six for PY2 compatability since our dependencies are not, PY2
  is legacy.
* Removed usages of utils from future/past libraries since they are
  deprecated. This includes 'from __future__ ...' and 'from past...'
  statements.
* Removed compatibility imports for PY2, switched from six imports to
  standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
  versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass
2021-05-26 15:31:29 +05:30
Aditya Hase
e54694dbf4
fix(recorder): Error page rendering shouldn't fail when recorder is active 2020-10-28 09:36:39 +05:30
Aditya Hase
cb294329ad style: Black + Flake8 2020-05-08 15:35:53 +05:30
Aditya Hase
2ed69034cb perf(recorder): Don't store context (code) and frame locals 2020-05-08 15:34:55 +05:30
Rushabh Mehta
1c893e44c0 fix: frappe.conf.db_type -> frappe.db.db_type 2019-05-24 11:44:28 +05:30
Aditya Hase
d0f83f3420 style: Linting fixes 2019-03-14 14:49:15 +05:30
Aditya Hase
567d4247b0 fix(recorder): Show better stack trace 2019-03-13 21:22:02 +05:30
Faris Ansari
b61a37a233 fix: Notification test in Postgres (#7044) 2019-03-08 20:47:21 +05:30
Aditya Hase
e034979b16 fix(recorder): use cursor.query to obtain executed query for postgres 2019-02-19 21:58:58 +05:30
Aditya Hase
58367b7df7 fix(recorder): Use EXPLAIN instead of EXPLAIN EXTENDED
EXPLAIN EXTENDED is not a valid postgres query, use EXPLAIN instead
2019-02-19 21:58:58 +05:30
Aditya Hase
e33563e24c test(recorder): Add python tests for recorder 2019-02-19 21:58:58 +05:30
Aditya Hase
0aaa7fcfd1 fix(recorder): Only allow Administrator to use Recorder 2019-02-19 21:58:58 +05:30
Aditya Hase
a9238c874d feat(recorder): Identify duplicate queries 2019-02-19 21:58:58 +05:30
Aditya Hase
f83d1be9af feat(recorder): Add paging in SQL queries table 2019-02-19 21:58:58 +05:30
Aditya Hase
7ef273cf82 fix(recorder): Cleanup
Add breadcrumb for backward navigation
Add Table view for SQL Explain
Add __debug__ check for NOOP in production
Remove unnecessary v-bind
Use router.push instead of router-link
Route to request-detail page if route is set to /request/:id
2019-02-19 21:58:58 +05:30
Aditya Hase
488a23b7c6 fix(recorder): Yield smaller stack trace 2019-02-19 21:58:58 +05:30
Aditya Hase
614a8f0b46 refactor(Recorder): Cleanup 2019-02-19 21:58:58 +05:30
Aditya Hase
1e1456afa0 refactor(recorder): Rename uuid to id 2019-02-19 21:58:58 +05:30
Aditya Hase
426642a7ee fix(recorder): Remove unused code 2019-02-19 21:58:58 +05:30
Aditya Hase
451eb01cdc refactor(recorder): Refactor API 2019-02-19 21:58:58 +05:30
Aditya Hase
8ba1b7e527 refactor(recorder): New decorator do_not_record 2019-02-19 21:58:58 +05:30
Aditya Hase
3ce2cf28e5 fix(recorder): Remove recoder web page 2019-02-19 21:58:57 +05:30
Aditya Hase
804dabbe6a feat(recorder): Show requests count in list view 2019-02-19 21:58:57 +05:30
Aditya Hase
1ad73f61bd feat(recorder): Enhanced list view 2019-02-19 21:58:57 +05:30
Aditya Hase
cdde489d7b feat(recorder): Add time on queries column in request list 2019-02-19 21:58:57 +05:30
Aditya Hase
0bf2d3f830 feat(recorder): Show query count in request list 2019-02-19 21:58:57 +05:30
Aditya Hase
d9c2fab892 feat(recorder): Interactive table for sql list 2019-02-19 21:58:57 +05:30
Aditya Hase
5b4ec4dc22 fix(recorder): Show query execution time in ms 2019-02-19 21:58:57 +05:30
Aditya Hase
b0faf64386 style: Linting fixes 2019-02-19 21:58:57 +05:30
Aditya Hase
10f8fad12d fix(recorder): Sort based on cmd correctly 2019-02-19 21:58:57 +05:30
Aditya Hase
d0b8d0fa0f feat(recorder): Show duration field in request list 2019-02-19 21:58:57 +05:30
Aditya Hase
f2afceb6e2 feat(recorder): Update request list in realtime 2019-02-19 21:58:57 +05:30
Aditya Hase
cca0d75695 feat(recorder): Render SQL results properly in table 2019-02-19 21:58:56 +05:30
Aditya Hase
fddbb7b94e fix(recorder): Generate valid dict for empty explain_result 2019-02-19 21:58:56 +05:30
Aditya Hase
7ddece641d fix(recorder): Reduce verbosity of SQL Profile results 2019-02-19 21:58:56 +05:30
Aditya Hase
e43ee8e6e5 fix(recorder): Start SQL profiling before all queries 2019-02-19 21:58:56 +05:30
Aditya Hase
226951d53c refactor(recorder): No need to sqlparse.format query twice 2019-02-19 21:58:56 +05:30
Aditya Hase
256912153f feat(recorder): Show Profile, EXPLAIN and query result in a table 2019-02-19 21:58:56 +05:30