File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
internal-packages/database/prisma Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 11import { LoaderFunctionArgs } from "@remix-run/server-runtime" ;
2+ import { prisma } from "~/db.server" ;
23import { metricsRegister } from "~/metrics.server" ;
34
45export async function loader ( { request } : LoaderFunctionArgs ) {
5- return new Response ( await metricsRegister . metrics ( ) , {
6+ // If the TRIGGER_METRICS_AUTH_PASSWORD is set, we need to check if the request has the correct password in auth header
7+ const authPassword = process . env . TRIGGER_METRICS_AUTH_PASSWORD ;
8+
9+ if ( authPassword ) {
10+ const auth = request . headers . get ( "Authorization" ) ;
11+ if ( auth !== `Bearer ${ authPassword } ` ) {
12+ return new Response ( "Unauthorized" , { status : 401 } ) ;
13+ }
14+ }
15+
16+ const prismaMetrics = await prisma . $metrics . prometheus ( ) ;
17+ const coreMetrics = await metricsRegister . metrics ( ) ;
18+
19+ return new Response ( coreMetrics + prismaMetrics , {
620 headers : {
721 "Content-Type" : metricsRegister . contentType ,
822 } ,
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ datasource db {
77generator client {
88 provider = " prisma-client-js "
99 binaryTargets = [" native " , " debian-openssl-1.1.x " ]
10- previewFeatures = [" tracing " ]
10+ previewFeatures = [" tracing " , " metrics " ]
1111}
1212
1313model User {
You can’t perform that action at this time.
0 commit comments