deanStealth
deanStealth
PPrisma
Created by deanStealth on 1/8/2025 in #help-and-questions
Prisma Promises not transferring context like Promises?
@RaphaelEtim now way to get them to move this log then to the context of where SQL was run for ease of devops people? (wanting to see the request id the SQL ran with).
13 replies
PPrisma
Created by deanStealth on 1/8/2025 in #help-and-questions
Prisma Promises not transferring context like Promises?
@RaphaelEtim it sounds like they only need to move the log statement for SQL to just after the SQL so it runs in the same context. Can that be done. very useful for devops logging and tracing.
13 replies
PPrisma
Created by deanStealth on 1/8/2025 in #help-and-questions
Prisma Promises not transferring context like Promises?
A simple testcase is this asyncLocalStorage.run(new Map(), () => { const store = asyncLocalStorage.getStore(); store.set("test", "myvalue"); const userDbo: CustomerWithCompany | null = await this._prisma.customerDbo.findUnique({ where: { id: userDbId }, include: { roles: true, company: true }, }); }); and then after that passing a logger with a public info(msg: string): void { asyncLocalStorage.getStore().get("test") and basically if that works, we get to thread reqId through all the SQL logs which is great for filtering in devops work.
13 replies
PPrisma
Created by deanStealth on 1/8/2025 in #help-and-questions
Prisma Promises not transferring context like Promises?
@wmadden I think @aqrln is correct in the log is not running in the same request context as the SQL and I wonder, can we have a log there (OR AT LEAST a config option so I can turn on logging on the SQL request context thread so the context of the SQL run is available in the log)
13 replies
PPrisma
Created by deanStealth on 1/8/2025 in #help-and-questions
Prisma Promises not transferring context like Promises?
or perhaps we could have a configuration option to log on the request context? currently, my SQL logs """[INFO ] 11T10:05:08.588 [,,,]: SQL Query Duration:""" vs. all my other logs """[INFO ] 11T10:08:26.29 [573647,[email protected],OURS-1fc96,c6ac139]""" BASICALLY in GCP when I filter by [email protected], all my SQL logs dissapear and I want to see what SQL was being run for that user since he ran into an error and there is tons of SQL logs and I can't map which user ran that SQL.
13 replies
PPrisma
Created by deanStealth on 1/8/2025 in #help-and-questions
Prisma Promises not transferring context like Promises?
@aqrln oh, oh!! ouch! I am very used to there being a request context (scala twitter promises as example) so that any code until request is done is on the same context such that very easy to debug performance issues and tie which SQL was running for which request due to the async context. After all, my request cannot complete without the data from the db which means as long as they do logger.info() on that same context before returning back to the client, we should be all good. can't we move the SQL Query Duration log to be done in that context? This seems like critical help in operations. I have confusion on "may even be emitted after the Prisma operation had already been finished" -> This is only true for logs, yes, as my client requires the transaction to be complete before I return to client OR even requires that I have the data which means the log could be on the request context and that would be ideal.
13 replies