wrapping of queries

I want to wrap all/some of my queries to instrument them for observability

import { type SQLWrapper } from "drizzle-orm";
type DrizzleQuery<T> = SQLWrapper & Promise<T>;

export async function instrument<T>(query: DrizzleQuery<T>): Promise<T> {
  logger.debug(`QUERY: `, query.toSQL())
  return await query;
}


The types are wrong. What would be the way to do this correctly?
Was this page helpful?