How to use the @opencensus/instrumentation-http.registerAllViews function in @opencensus/instrumentation-http

To help you get started, we’ve selected a few @opencensus/instrumentation-http examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github magma / magma / symphony / app / fbcnms-projects / platform-server / scripts / server.js View on Github external
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(':')