Track queries with Sentry
This commit is contained in:
parent
709675754c
commit
c532f54ea6
|
@ -0,0 +1,11 @@
|
||||||
|
import { Conf } from './config.ts';
|
||||||
|
import { Sentry } from './deps.ts';
|
||||||
|
|
||||||
|
// Sentry
|
||||||
|
if (Conf.sentryDsn) {
|
||||||
|
console.log('Sentry enabled');
|
||||||
|
Sentry.init({
|
||||||
|
dsn: Conf.sentryDsn,
|
||||||
|
tracesSampleRate: 1.0,
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,15 +1,5 @@
|
||||||
import './precheck.ts';
|
import './precheck.ts';
|
||||||
|
import './sentry.ts';
|
||||||
import app from './app.ts';
|
import app from './app.ts';
|
||||||
import { Conf } from './config.ts';
|
|
||||||
import { Sentry } from './deps.ts';
|
|
||||||
|
|
||||||
// Sentry
|
|
||||||
if (Conf.sentryDsn) {
|
|
||||||
console.log('Sentry enabled');
|
|
||||||
Sentry.init({
|
|
||||||
dsn: Conf.sentryDsn,
|
|
||||||
tracesSampleRate: 1.0,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Deno.serve(app.fetch);
|
Deno.serve(app.fetch);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/// <reference lib="webworker" />
|
/// <reference lib="webworker" />
|
||||||
|
|
||||||
import { Comlink, type CompiledQuery, DenoSqlite3, type QueryResult } from '@/deps.ts';
|
import { Comlink, type CompiledQuery, DenoSqlite3, type QueryResult, Sentry } from '@/deps.ts';
|
||||||
|
import '@/sentry.ts';
|
||||||
|
|
||||||
let db: DenoSqlite3 | undefined;
|
let db: DenoSqlite3 | undefined;
|
||||||
|
|
||||||
|
@ -10,11 +11,16 @@ export const SqliteWorker = {
|
||||||
},
|
},
|
||||||
executeQuery<R>({ sql, parameters }: CompiledQuery): QueryResult<R> {
|
executeQuery<R>({ sql, parameters }: CompiledQuery): QueryResult<R> {
|
||||||
if (!db) throw new Error('Database not open');
|
if (!db) throw new Error('Database not open');
|
||||||
|
|
||||||
|
const result: QueryResult<R> = Sentry.startSpan({ name: sql, op: 'db.query' }, () => {
|
||||||
return {
|
return {
|
||||||
rows: db.prepare(sql).all(...parameters as any[]) as R[],
|
rows: db!.prepare(sql).all(...parameters as any[]) as R[],
|
||||||
numAffectedRows: BigInt(db.changes),
|
numAffectedRows: BigInt(db!.changes),
|
||||||
insertId: BigInt(db.lastInsertRowId),
|
insertId: BigInt(db!.lastInsertRowId),
|
||||||
};
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
},
|
},
|
||||||
destroy() {
|
destroy() {
|
||||||
db?.close();
|
db?.close();
|
||||||
|
|
Loading…
Reference in New Issue