2021-08-20 21:09:34 +08:00
|
|
|
import Agent from './promAgent.js';
|
2021-10-07 02:55:19 +08:00
|
|
|
|
2021-08-24 04:39:53 +08:00
|
|
|
import {
|
|
|
|
METRICS_PREFIX,
|
|
|
|
METRIC_NAMES,
|
|
|
|
buildMetrics
|
|
|
|
} from './metrics.js';
|
2021-10-07 02:55:19 +08:00
|
|
|
|
|
|
|
const {
|
|
|
|
enabled: METRICS_ENABLED,
|
|
|
|
path: METRICS_PATH,
|
|
|
|
collectDefaultMetrics: COLLECT_DEFAULT_METRICS,
|
|
|
|
} = Meteor.settings.private.prometheus
|
|
|
|
? Meteor.settings.private.prometheus
|
|
|
|
: { enabled: false };
|
|
|
|
|
2021-11-06 00:31:23 +08:00
|
|
|
const PrometheusAgent = new Agent({
|
2021-10-07 02:55:19 +08:00
|
|
|
path: METRICS_PATH,
|
|
|
|
prefix: METRICS_PREFIX,
|
|
|
|
collectDefaultMetrics: COLLECT_DEFAULT_METRICS,
|
2021-11-06 00:31:23 +08:00
|
|
|
role: process.env.BBB_HTML5_ROLE,
|
|
|
|
instanceId: parseInt(process.env.INSTANCE_ID, 10) || 1,
|
2021-10-07 02:55:19 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
if (METRICS_ENABLED) {
|
2021-08-24 04:39:53 +08:00
|
|
|
PrometheusAgent.injectMetrics(buildMetrics());
|
2021-08-20 01:39:59 +08:00
|
|
|
PrometheusAgent.start();
|
2021-10-07 02:55:19 +08:00
|
|
|
}
|
|
|
|
|
2021-08-24 04:39:53 +08:00
|
|
|
export {
|
|
|
|
METRIC_NAMES,
|
2021-10-07 02:55:19 +08:00
|
|
|
METRICS_PREFIX,
|
|
|
|
Agent,
|
2021-08-20 01:39:59 +08:00
|
|
|
PrometheusAgent,
|
2021-11-06 00:31:23 +08:00
|
|
|
};
|