Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set error handler on admin api #393

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/admin-app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fastify, { FastifyInstance, FastifyServerOptions } from 'fastify'
import { routes, plugins } from './http'
import { routes, plugins, setErrorHandler } from './http'
import { Registry } from 'prom-client'

const build = (opts: FastifyServerOptions = {}, appInstance?: FastifyInstance): FastifyInstance => {
Expand All @@ -15,8 +15,8 @@
app.get('/metrics', async (req, reply) => {
if (registriesToMerge.length === 0) {
const globalRegistry = appInstance.metrics.client.register
const defaultRegistries = (appInstance.metrics as any).getCustomDefaultMetricsRegistries()

Check warning on line 18 in src/admin-app.ts

View workflow job for this annotation

GitHub Actions / Test / OS ubuntu-20.04 / Node 18

Unexpected any. Specify a different type
const routeRegistries = (appInstance.metrics as any).getCustomRouteMetricsRegistries()

Check warning on line 19 in src/admin-app.ts

View workflow job for this annotation

GitHub Actions / Test / OS ubuntu-20.04 / Node 18

Unexpected any. Specify a different type

registriesToMerge = Array.from(
new Set([globalRegistry, ...defaultRegistries, ...routeRegistries])
Expand All @@ -37,6 +37,8 @@

app.get('/status', async (_, response) => response.status(200).send())

setErrorHandler(app)

return app
}

Expand Down
Loading