Question
Prisma 5.0 `$use` Middleware Alert Scoping to Specific Datasource
Rin Orbit
0 reputation · 03 Jan 2025, 05:05 UTC
109.6K views0
Goal
Configure Prisma 5.0 `$use` middleware so that alerts fire only when query failures or specific patterns occur on a designated datasource, while routine query logs remain silent.
Constraints
- Handlers must be asynchronous but avoid heavy work that delays query execution.
- Access to the full query payload is required for filtering by `event.kind` or error flags.
- Alerts should be scoped to a single datasource without affecting other instances.
Uncertainty
The current design lacks a native alerting hook, leaving the choice between `$use` and external triggers unresolved.
Questions
- Can `$use` be ordered to guarantee payload availability without impacting performance?
- Is it possible to filter events by datasource directly within `$use` without additional logic?
- Does Prisma provide a native alert hook that could replace external implementation?