diff --git a/meteor/.meteor/packages b/meteor/.meteor/packages index 5e5686dab9..1bf669c4dc 100644 --- a/meteor/.meteor/packages +++ b/meteor/.meteor/packages @@ -33,4 +33,4 @@ meteorhacks:picker ostrio:meteor-root accounts-password@2.3.1 -# kschingiz:meteor-elastic-apm +julusian:meteor-elastic-apm@2.5.2 diff --git a/meteor/.meteor/versions b/meteor/.meteor/versions index 439f82c1ff..3481df490f 100644 --- a/meteor/.meteor/versions +++ b/meteor/.meteor/versions @@ -34,6 +34,8 @@ html-tools@1.1.3 htmljs@1.1.1 id-map@1.1.1 inter-process-messaging@0.1.1 +julusian:meteor-elastic-apm@2.5.2 +kschingiz:meteor-measured@1.0.3 launch-screen@1.3.0 localstorage@1.2.0 logging@1.3.1 diff --git a/meteor/__mocks__/_setupMocks.ts b/meteor/__mocks__/_setupMocks.ts index 467eb8f426..23de3d894c 100644 --- a/meteor/__mocks__/_setupMocks.ts +++ b/meteor/__mocks__/_setupMocks.ts @@ -25,9 +25,9 @@ jest.mock('meteor/reactive-var', (...args) => require('./reactive-var').setup(ar jest.mock('meteor/meteorhacks:picker', (...args) => require('./meteorhacks-picker').setup(args), { virtual: true }) jest.mock('meteor/mdg:validated-method', (...args) => require('./validated-method').setup(args), { virtual: true }) -// jest.mock('meteor/kschingiz:meteor-elastic-apm', (...args) => require('./meteor-elastic-apm').setup(args), { -// virtual: true, -// }) +jest.mock('meteor/julusian:meteor-elastic-apm', (...args) => require('./meteor-elastic-apm').setup(args), { + virtual: true, +}) jest.mock('meteor/mongo', (...args) => require('./mongo').setup(args), { virtual: true }) diff --git a/meteor/server/api/profiler.ts b/meteor/server/api/profiler.ts index 9a1fd2f381..357f0a743c 100644 --- a/meteor/server/api/profiler.ts +++ b/meteor/server/api/profiler.ts @@ -1,27 +1,4 @@ -/* - Note: meteor-elastic-apm has been temporarily disabled due to being incompatible Meteor 2.3 - See https://github.com/Meteor-Community-Packages/meteor-elastic-apm/pull/61 - So instead I've just added a temporary black-hole replacement for now /Johan Nyman 2022-01-18 -*/ -type StartSpan = (name: string) => undefined | { end: Function; addLabels: Function } -type StartTransaction = ( - description: string, - name: string -) => undefined | { end: Function; addLabels: Function; startSpan: StartSpan } - -const Agent: { - startSpan: StartSpan - startTransaction: StartTransaction -} = { - startSpan: (_name: string) => { - return undefined - }, - startTransaction: (_descr: string, _name: string) => { - return undefined - }, -} - -// import Agent from 'meteor/kschingiz:meteor-elastic-apm' +import Agent from 'meteor/julusian:meteor-elastic-apm' class Profiler { private active: boolean = false diff --git a/meteor/server/coreSystem/index.ts b/meteor/server/coreSystem/index.ts index 1795e3a2e3..9c535229be 100644 --- a/meteor/server/coreSystem/index.ts +++ b/meteor/server/coreSystem/index.ts @@ -6,8 +6,8 @@ import { CURRENT_SYSTEM_VERSION } from '../migration/currentSystemVersion' import { Blueprints, CoreSystem, ShowStyleBases, ShowStyleVariants, Studios } from '../collections' import { getEnvLogLevel, logger, LogLevel, setLogLevel } from '../logging' const PackageInfo = require('../../package.json') -// import Agent from 'meteor/kschingiz:meteor-elastic-apm' -// import { profiler } from './api/profiler' +import Agent from 'meteor/julusian:meteor-elastic-apm' +import { profiler } from '../api/profiler' import { TMP_TSR_VERSION } from '@sofie-automation/blueprints-integration' import { getAbsolutePath } from '../lib' import * as fs from 'fs/promises' @@ -184,33 +184,29 @@ function startInstrumenting() { } // attempt init elastic APM - - // Note: meteor-elastic-apm has been temporarily disabled due to being incompatible Meteor 2.3 - // See https://github.com/Meteor-Community-Packages/meteor-elastic-apm/pull/61 - // - // const system = getCoreSystem() - // const { APM_HOST, APM_SECRET, KIBANA_INDEX, APP_HOST } = process.env - - // if (APM_HOST && system && system.apm) { - // logger.info(`APM agent starting up`) - // Agent.start({ - // serviceName: KIBANA_INDEX || 'tv-automation-server-core', - // hostname: APP_HOST, - // serverUrl: APM_HOST, - // secretToken: APM_SECRET, - // active: system.apm.enabled, - // transactionSampleRate: system.apm.transactionSampleRate, - // disableMeteorInstrumentations: ['methods', 'http-out', 'session', 'async', 'metrics'], - // }) - // profiler.setActive(system.apm.enabled || false) - // } else { - // logger.info(`APM agent inactive`) - // Agent.start({ - // serviceName: 'tv-automation-server-core', - // active: false, - // disableMeteorInstrumentations: ['methods', 'http-out', 'session', 'async', 'metrics'], - // }) - // } + const system = getCoreSystem() + const { APM_HOST, APM_SECRET, KIBANA_INDEX, APP_HOST } = process.env + + if (APM_HOST && system && system.apm) { + logger.info(`APM agent starting up`) + Agent.start({ + serviceName: KIBANA_INDEX || 'tv-automation-server-core', + hostname: APP_HOST, + serverUrl: APM_HOST, + secretToken: APM_SECRET, + active: system.apm.enabled, + transactionSampleRate: system.apm.transactionSampleRate, + disableMeteorInstrumentations: ['methods', 'http-out', 'session', 'async', 'metrics'], + }) + profiler.setActive(system.apm.enabled || false) + } else { + logger.info(`APM agent inactive`) + Agent.start({ + serviceName: 'tv-automation-server-core', + active: false, + disableMeteorInstrumentations: ['methods', 'http-out', 'session', 'async', 'metrics'], + }) + } } function updateLoggerLevel(startup: boolean) { if (Meteor.isTest) return // ignore this when running in tests diff --git a/meteor/server/typings/meteor-kschingiz-elastic-apm.d.ts b/meteor/server/typings/meteor-kschingiz-elastic-apm.d.ts index f033338b92..f5e6619843 100644 --- a/meteor/server/typings/meteor-kschingiz-elastic-apm.d.ts +++ b/meteor/server/typings/meteor-kschingiz-elastic-apm.d.ts @@ -3,11 +3,7 @@ * As they do not export any of the inner types, adding `disableMeteorInstrumentations` to `AgentConfigOptions` is not trivial without just copying it all */ -/* -Note: meteor-elastic-apm has been temporarily disabled due to being incompatible Meteor 2.3 -See https://github.com/Meteor-Community-Packages/meteor-elastic-apm/pull/61 - -declare module 'meteor/kschingiz:meteor-elastic-apm' { +declare module 'meteor/julusian:meteor-elastic-apm' { /// import { IncomingMessage, ServerResponse } from 'http' @@ -357,4 +353,3 @@ declare module 'meteor/kschingiz:meteor-elastic-apm' { type ErrorHandleFunction = (err: any, req: IncomingMessage, res: ServerResponse, next: NextFunction) => void } } -*/