|
4 | 4 | errors_total, |
5 | 5 | execute_many_total, |
6 | 6 | execute_total, |
| 7 | + query_duration_seconds, |
7 | 8 | ) |
8 | 9 |
|
9 | 10 |
|
@@ -57,21 +58,23 @@ def ExportingCursorWrapper(cursor_class, alias, vendor): |
57 | 58 | vendor name. |
58 | 59 | """ |
59 | 60 |
|
| 61 | + labels = {"alias": alias, "vendor": vendor} |
| 62 | + |
60 | 63 | class CursorWrapper(cursor_class): |
61 | 64 | """Extends the base CursorWrapper to count events.""" |
62 | 65 |
|
63 | 66 | def execute(self, *args, **kwargs): |
64 | 67 | execute_total.labels(alias, vendor).inc() |
65 | | - with ExceptionCounterByType( |
66 | | - errors_total, extra_labels={"alias": alias, "vendor": vendor} |
| 68 | + with query_duration_seconds.labels(**labels).time(), ( |
| 69 | + ExceptionCounterByType(errors_total, extra_labels=labels) |
67 | 70 | ): |
68 | 71 | return super(CursorWrapper, self).execute(*args, **kwargs) |
69 | 72 |
|
70 | 73 | def executemany(self, query, param_list, *args, **kwargs): |
71 | 74 | execute_total.labels(alias, vendor).inc(len(param_list)) |
72 | 75 | execute_many_total.labels(alias, vendor).inc(len(param_list)) |
73 | | - with ExceptionCounterByType( |
74 | | - errors_total, extra_labels={"alias": alias, "vendor": vendor} |
| 76 | + with query_duration_seconds.labels(**labels).time(), ( |
| 77 | + ExceptionCounterByType(errors_total, extra_labels=labels) |
75 | 78 | ): |
76 | 79 | return super(CursorWrapper, self).executemany( |
77 | 80 | query, param_list, *args, **kwargs |
|
0 commit comments