66} from '@sofie-automation/meteor-lib/dist/api/systemStatus'
77import { getDebugStates , getSystemStatus } from './systemStatus'
88import { protectString } from '../lib/tempLib'
9- import { Settings } from '../Settings'
109import { MethodContextAPI } from '../api/methodContext'
1110import { profiler } from '../api/profiler'
1211import { PeripheralDeviceId } from '@sofie-automation/corelib/dist/dataModel/Ids'
@@ -22,53 +21,38 @@ const apmNamespace = 'http'
2221export const metricsRouter = new KoaRouter ( )
2322export const healthRouter = new KoaRouter ( )
2423
25- if ( ! Settings . enableUserAccounts ) {
26- // For backwards compatibility:
24+ metricsRouter . get ( '/' , async ( ctx ) => {
25+ const transaction = profiler . startTransaction ( 'metrics' , apmNamespace )
26+ try {
27+ ctx . response . type = PrometheusHTTPContentType
2728
28- metricsRouter . get ( '/' , async ( ctx ) => {
29- const transaction = profiler . startTransaction ( 'metrics' , apmNamespace )
30- try {
31- ctx . response . type = PrometheusHTTPContentType
29+ const [ meteorMetrics , workerMetrics ] = await Promise . all ( [
30+ getPrometheusMetricsString ( ) ,
31+ collectWorkerPrometheusMetrics ( ) ,
32+ ] )
3233
33- const [ meteorMetrics , workerMetrics ] = await Promise . all ( [
34- getPrometheusMetricsString ( ) ,
35- collectWorkerPrometheusMetrics ( ) ,
36- ] )
37-
38- ctx . body = [ meteorMetrics , ...workerMetrics ] . join ( '\n\n' )
39- } catch ( ex ) {
40- ctx . response . status = 500
41- ctx . body = ex + ''
42- }
43- transaction ?. end ( )
44- } )
45-
46- healthRouter . get ( '/' , async ( ctx ) => {
47- const transaction = profiler . startTransaction ( 'health' , apmNamespace )
48- const status = await getSystemStatus ( ctx )
49- health ( status , ctx )
50- transaction ?. end ( )
51- } )
34+ ctx . body = [ meteorMetrics , ...workerMetrics ] . join ( '\n\n' )
35+ } catch ( ex ) {
36+ ctx . response . status = 500
37+ ctx . body = ex + ''
38+ }
39+ transaction ?. end ( )
40+ } )
5241
53- healthRouter . get ( '/:studioId' , async ( ctx ) => {
54- const transaction = profiler . startTransaction ( 'health' , apmNamespace )
55- const status = await getSystemStatus ( ctx , protectString ( ctx . params . studioId ) )
56- health ( status , ctx )
57- transaction ?. end ( )
58- } )
59- }
60- healthRouter . get ( '/:token' , async ( ctx ) => {
42+ healthRouter . get ( '/' , async ( ctx ) => {
6143 const transaction = profiler . startTransaction ( 'health' , apmNamespace )
6244 const status = await getSystemStatus ( ctx )
6345 health ( status , ctx )
6446 transaction ?. end ( )
6547} )
66- healthRouter . get ( '/:token/:studioId' , async ( ctx ) => {
48+
49+ healthRouter . get ( '/:studioId' , async ( ctx ) => {
6750 const transaction = profiler . startTransaction ( 'health' , apmNamespace )
6851 const status = await getSystemStatus ( ctx , protectString ( ctx . params . studioId ) )
6952 health ( status , ctx )
7053 transaction ?. end ( )
7154} )
55+
7256function health ( status : StatusResponse , ctx : Koa . ParameterizedContext ) {
7357 ctx . response . type = 'application/json'
7458
0 commit comments