diff --git a/src/sentry.ts b/src/sentry.ts
new file mode 100644
index 0000000..eefe9c5
--- /dev/null
+++ b/src/sentry.ts
@@ -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,
+ });
+}
diff --git a/src/server.ts b/src/server.ts
index 9dbb449..2a1906b 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -1,15 +1,5 @@
import './precheck.ts';
+import './sentry.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);
diff --git a/src/workers/sqlite.worker.ts b/src/workers/sqlite.worker.ts
index c79f078..6f42213 100644
--- a/src/workers/sqlite.worker.ts
+++ b/src/workers/sqlite.worker.ts
@@ -1,6 +1,7 @@
///
-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;
@@ -10,11 +11,16 @@ export const SqliteWorker = {
},
executeQuery({ sql, parameters }: CompiledQuery): QueryResult {
if (!db) throw new Error('Database not open');
- return {
- rows: db.prepare(sql).all(...parameters as any[]) as R[],
- numAffectedRows: BigInt(db.changes),
- insertId: BigInt(db.lastInsertRowId),
- };
+
+ const result: QueryResult = Sentry.startSpan({ name: sql, op: 'db.query' }, () => {
+ return {
+ rows: db!.prepare(sql).all(...parameters as any[]) as R[],
+ numAffectedRows: BigInt(db!.changes),
+ insertId: BigInt(db!.lastInsertRowId),
+ };
+ });
+
+ return result;
},
destroy() {
db?.close();