mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-07 07:34:25 +01:00
Merge branch 'db-query-time-prom-metric' into 'main'
basic (and incredibly stupid but potentially genius) db_query_time histogram See merge request soapbox-pub/ditto!400
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Stickynotes } from '@soapbox/stickynotes';
|
||||
import { Logger } from 'kysely';
|
||||
import { dbQueryTimeHistogram } from '@/metrics.ts';
|
||||
|
||||
/** Log the SQL for queries. */
|
||||
export const KyselyLogger: Logger = (event) => {
|
||||
@@ -9,6 +10,8 @@ export const KyselyLogger: Logger = (event) => {
|
||||
const { query, queryDurationMillis } = event;
|
||||
const { sql, parameters } = query;
|
||||
|
||||
dbQueryTimeHistogram.observe(queryDurationMillis);
|
||||
|
||||
console.debug(
|
||||
sql,
|
||||
JSON.stringify(parameters),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Counter, Gauge } from 'prom-client';
|
||||
import { Counter, Gauge, Histogram } from 'prom-client';
|
||||
|
||||
export const httpRequestCounter = new Counter({
|
||||
name: 'http_requests_total',
|
||||
@@ -67,3 +67,8 @@ export const dbAvailableConnectionsGauge = new Gauge({
|
||||
name: 'db_available_connections',
|
||||
help: 'Number of available connections in the database pool',
|
||||
});
|
||||
|
||||
export const dbQueryTimeHistogram = new Histogram({
|
||||
name: 'db_query_duration_seconds',
|
||||
help: 'Duration of database queries',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user