How to use the elastic-apm-node.start function in elastic-apm-node

To help you get started, we’ve selected a few elastic-apm-node 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 sozialhelden / wheelmap-frontend / src / lib / apm / ServerSide.js View on Github external
const apmNode = require('elastic-apm-node');
const env = require('../env');

console.log('Starting server side APM.');
const apm = apmNode.start({
  serviceName: 'wheelmap-react-frontend',
  serviceVersion: env.npm_package_version, // Used on the APM Server to find the right sourcemap
  serverUrl: env.ELASTIC_APM_SERVER_URL,
  secretToken: env.ELASTIC_APM_SECRET_TOKEN,
});

module.exports = apm;
github jsdelivr / data.jsdelivr.com / src / index.js View on Github external
// istanbul ignore next
if (require.main === module) {
	// This needs to run before any require() call.
	global.apmClient = require('elastic-apm-node').start({});
	global.apmClient.addTransactionFilter(payload => (payload.context && payload.context.tags && payload.context.tags.userAgent && !payload.context.tags.userAgent.includes('sindresorhus/got')) || Math.random() < .2 ? payload : false);
	global.apmClient.addTransactionFilter(require('elastic-apm-utils').apm.transactionFilter());
	global.apmClient.addSpanFilter(require('elastic-apm-utils').apm.spanFilter({ filterShorterThan: 10 }));
	require('./lib/startup');
}

const config = require('config');
const signalExit = require('signal-exit');
const Koa = require('koa');
const koaFavicon = require('koa-favicon');
const koaResponseTime = require('koa-response-time');
const koaConditionalGet = require('koa-conditional-get');
const koaCompress = require('koa-compress');
const koaLogger = require('koa-logger');
const koaETag = require('koa-etag');
const koaJson = require('koa-json');
github yidinghan / eak / test-app / app.js View on Github external
require('elastic-apm-node').start({
    serviceName: 'test-app',
    serverUrl: `http://${process.env.apmserver}:8200`,
    logLevel: 'info',
});
const http = require('http');

const name = 'node-hello-world';
const port = '8888';

const app = new http.Server();

app.on('request', (req, res) => {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.write('Hello World');
    res.end('\n');
});
github elastic / apm-integration-testing / docker / nodejs / express / app.js View on Github external
'use strict'

var apm = require('elastic-apm-node').start({
  frameworkName: 'express',
  frameworkVersion: 'unknown',
  serviceName: process.env.EXPRESS_SERVICE_NAME,
  flushInterval: 1,
  maxQueueSize: 1,
  apiRequestTime: "50ms",
  ignoreUrls: ['/healthcheck']
})

var app = require("express")();

app.get("/", function(req, res) {
    res.send("OK");
});

app.get("/healthcheck", function(req, res) {
github elastic / apm-server / tests / agent / nodejs / express / app.js View on Github external
'use strict'

var apm = require('elastic-apm-node').start({
  appName: 'test-app', flushInterval: 1
})


var app = require("express")();

app.get("/", function(req, res) {
    res.send("OK");
});

app.get("/foo", function(req, res) {
    foo_route()
    res.send("OK");
});

function foo_route () {
github shadowlik / muchas-framework / src / Apm.ts View on Github external
export = (name: string, nodeEnv: string, apmOptions: ApmOptions | undefined): any => {
    if (!name || !apmOptions) return undefined;

    const logLevel: LovLevel = apmOptions.loglevel;
    const opt: any = {
        transactionSampleRate: apmOptions.sample,
        serviceName: nodeEnv === 'production' ?
            name :
            `${name}-${nodeEnv || 'development'}`,
        serverUrl: apmOptions.apmHost,
        logLevel,
    };

    if (apmOptions.token)  opt.secretToken = apmOptions.token;

    return apm.start(opt);
};
github jsdelivr / data.jsdelivr.com / src / lib / precache / run.js View on Github external
global.apmClient = require('elastic-apm-node').start({});
require('../startup');

const relativeDayUtc = require('relative-day-utc');
const V1StatsRequest = require('../../routes/lib/v1/StatsRequest');
const V1PackageRequest = require('../../routes/lib/v1/PackageRequest');
const Package = require('../../models/Package');

const PromiseLock = require('../promise-lock');
const promiseLock = new PromiseLock('pc');
const precacheLog = logger.scope('precache');

function makeCtx (params = {}, query = {}) {
	return { params, query };
}

function makeDateRange (defaultDays, daysInFuture) {
github elastic / kibana / src / apm.js View on Github external
module.exports = function(serviceName = name) {
  if (process.env.kbnWorkerType === 'optmzr') return;

  const conf = getConfig(serviceName);

  require('elastic-apm-node').start(conf);
};
github vpdb / server / src / app / index.ts View on Github external
* modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

if (process.env.ELASTIC_APM_ENABLED) {
	require('elastic-apm-node').start();
}
if (process.env.SQREEN_ENABLED) {
	require('sqreen');
}

import mongoose from 'mongoose';
import { init as initAcls } from './common/acl';
import { endPoints } from './common/api.endpoints';
import { logger } from './common/logger';
import { ModerationSerializer } from './common/mongoose/moderation.serializer';
import { config, settings } from './common/settings';
import { FileUtil } from './files/file.util';
import { server } from './server';
import { state } from './state';

const shortId = require('shortid32');