Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function enableHttpPlugin (tracer) {
// 1. Define node version
const version = process.versions.node;
// 2. Enable HTTP plugin
httpPlugin.plugin.enable(http, tracer, version, null);
}
import {PrometheusStatsExporter} from '@opencensus/exporter-prometheus';
import {globalStats} from '@opencensus/core';
import {registerAllViews} from '@opencensus/instrumentation-http';
import {runMigrations} from './runMigrations';
const {sequelize} = require('@fbcnms/sequelize-models');
const logger = logging.getLogger(module);
const port = parseInt(process.env.PORT || 80);
// Configure metrics
const prometheusExporter = new PrometheusStatsExporter({
startServer: true,
logger,
});
globalStats.registerExporter(prometheusExporter);
registerAllViews(globalStats);
let jaegerExporter = null;
if (process.env.TELEMETRY_TRACE_EXPORTER == 'jaeger') {
if (
!process.env.JAEGER_AGENT_ENDPOINT &&
!process.env.JAEGER_COLLECTOR_ENDPOINT
) {
throw new Error(
'When using TELEMETRY_TRACE_EXPORTER = "jaeger", you ' +
'must set either JAEGER_AGENT_ENDPOINT or JAEGER_COLLECTOR_ENDPOINT',
);
}
// Configure opencensus for jaeger
const agentEndpoint = process.env.JAEGER_AGENT_ENDPOINT;
const [agentHost, agentPort] = agentEndpoint
? agentEndpoint.split(':')
request.on('error', (err: Error) => {
span.addAttribute(HttpPlugin.ATTRIBUTE_HTTP_ERROR_NAME, err.name);
span.addAttribute(HttpPlugin.ATTRIBUTE_HTTP_ERROR_MESSAGE, err.message);
span.end();
});
request.on('error', (err: Error) => {
span.addAttribute(HttpPlugin.ATTRIBUTE_HTTP_ERROR_NAME, err.name);
span.addAttribute(HttpPlugin.ATTRIBUTE_HTTP_ERROR_MESSAGE, err.message);
span.end();
});