forked from Meteor-Community-Packages/meteor-elastic-apm
-
Notifications
You must be signed in to change notification settings - Fork 2
/
metrics.js
28 lines (23 loc) · 787 Bytes
/
metrics.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* eslint-disable no-console */
/* eslint-disable import/no-unresolved */
import meteorMeasured from 'meteor/kschingiz:meteor-measured';
function startMetrics(agent) {
const metrics = agent._metrics || {};
// ugly hack to find metrics registry
const registrySymbol = Object.getOwnPropertySymbols(metrics).find(
symbol => symbol.toString() === 'Symbol(metrics-registry)'
);
const registry = metrics[registrySymbol];
if (registry) {
try {
meteorMeasured(registry);
agent.logger.debug('Successfully started meteor-measured');
} catch (e) {
agent.logger.error('Metrics could not be started');
throw e;
}
} else {
agent.logger.error('Metrics could not be started, agent registry not found');
}
}
module.exports = startMetrics;