How to use @instana/core - 10 common examples

To help you get started, we’ve selected a few @instana/core 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 instana / nodejs-sensor / test / aws_lambda / common / tests_common.js View on Github external
/* eslint-env mocha */

'use strict';

const expect = require('chai').expect;
const path = require('path');
const constants = require('@instana/core').tracing.constants;

const config = require('../../config');
const delay = require('../../util/delay');
const expectOneMatching = require('../../util/expect_matching');
const retry = require('../../util/retry');

const functionName = 'functionName';
const unqualifiedArn = `arn:aws:lambda:us-east-2:410797082306:function:${functionName}`;
const version = '$LATEST';
const qualifiedArn = `${unqualifiedArn}:${version}`;

function prelude(opts) {
  this.timeout(config.getTestTimeout());
  this.slow(config.getTestTimeout() / 4);

  if (opts.startBackend == null) {
github instana / nodejs-sensor / packages / collector / src / logger.js View on Github external
if (process.env['INSTANA_DEBUG']) {
      parentLogger.level('debug');
    } else if (config.level) {
      parentLogger.level(config.level);
    } else if (process.env['INSTANA_LOG_LEVEL']) {
      parentLogger.level(process.env['INSTANA_LOG_LEVEL'].toLowerCase());
    }
  }

  if (isReInit) {
    Object.keys(registry).forEach(function(loggerName) {
      var reInitFn = registry[loggerName];
      reInitFn(exports.getLogger(loggerName));
    });
    // cascade re-init to @instana/core
    instanaNodeJsCore.logger.init(config);
  }
};
github instana / nodejs-sensor / packages / aws-lambda / src / wrapper.js View on Github external
function init(event, arnInfo, _config) {
  /* eslint-disable dot-notation */
  config = _config || {};

  if (config.logger) {
    logger = config.logger;
  } else if (config.level || process.env['INSTANA_LOG_LEVEL']) {
    logger.setLevel(config.level || process.env['INSTANA_LOG_LEVEL']);
  }
  identityProvider.init(arnInfo);
  backendConnector.init(identityProvider, logger);

  instanaCore.init(config, backendConnector, identityProvider);

  metrics.init(config);
  metrics.activate();
  tracing.activate();
}
github instana / nodejs-sensor / packages / aws-lambda / src / wrapper.js View on Github external
const { backendConnector, consoleLogger } = require('@instana/serverless');

const arnParser = require('./arn');
const identityProvider = require('./identity_provider');
const metrics = require('./metrics');
const triggers = require('./triggers');
const processResult = require('./process_result');

const { tracing } = instanaCore;
const { constants, spanBuffer } = tracing;
let logger = consoleLogger;
let config;

// Initialize instrumentations early to allow for require statements after our package has been required but before the
// actual instana.wrap(...) call.
instanaCore.preInit();

/**
 * Wraps an AWS Lambda handler so that metrics and traces are reported to Instana. This function will figure out if the
 * Lambda handler uses the callback style or promise/async function style by inspecting the number of function arguments
 * the function receives.
 */
exports.wrap = function wrap(_config, originalHandler) {
  /* eslint-disable no-unused-vars */
  if (arguments.length === 1) {
    originalHandler = _config;
    _config = null;
  }

  // Apparently the AWS Lambda Node.js runtime does not inspect the handlers signature for the number of arguments it
  // accepts. But to be extra safe, we strive to return a function with the same number of arguments anyway.
  switch (originalHandler.length) {
github instana / nodejs-sensor / packages / collector / src / announceCycle / agentHostLookup.js View on Github external
'use strict';

var atMostOnce = require('@instana/core').util.atMostOnce;
var exec = require('child_process').exec;
var http = require('@instana/core').uninstrumentedHttp.http;

var agentOpts = require('../agent/opts');

var logger;
logger = require('../logger').getLogger('announceCycle/agentHostLookup', function(newLogger) {
  logger = newLogger;
});

// Depending on the environment in which the agent and node collector are running,
// the agent may be available under different hosts. For instance,
// when the agent and collector are running on the same host outside any container,
// the host will probably be 127.0.0.1.
//
// A custom host can be set via agent options
github instana / nodejs-sensor / packages / collector / src / uncaught / index.js View on Github external
'use strict';

var serializeError = require('serialize-error');

var logger;
logger = require('../logger').getLogger('util/uncaughtExceptionHandler', function(newLogger) {
  logger = newLogger;
});

var instanaNodeJsCore = require('@instana/core');
var tracing = instanaNodeJsCore.tracing;
var spanBuffer = tracing.spanBuffer;
var stackTraceUtil = instanaNodeJsCore.util.stackTrace;

var downstreamConnection = null;
var processIdentityProvider = null;
var uncaughtExceptionEventName = 'uncaughtException';
var unhandledRejectionEventName = 'unhandledRejection';
var unhandledRejectionDeprecationWarningHasBeenEmitted = false;
var stackTraceLength = 10;
var config;

// see
// https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode /
// https://github.com/nodejs/node/pull/26599
var unhandledRejectionsMode = 'warn/default';
for (var i = 0; i < process.execArgv.length; i++) {
  if (process.execArgv[i] === '--unhandled-rejections=none') {
    unhandledRejectionsMode = 'none';
github instana / nodejs-sensor / packages / collector / src / uncaught / index.js View on Github external
'use strict';

var serializeError = require('serialize-error');

var logger;
logger = require('../logger').getLogger('util/uncaughtExceptionHandler', function(newLogger) {
  logger = newLogger;
});

var instanaNodeJsCore = require('@instana/core');
var tracing = instanaNodeJsCore.tracing;
var spanBuffer = tracing.spanBuffer;
var stackTraceUtil = instanaNodeJsCore.util.stackTrace;

var downstreamConnection = null;
var processIdentityProvider = null;
var uncaughtExceptionEventName = 'uncaughtException';
var unhandledRejectionEventName = 'unhandledRejection';
var unhandledRejectionDeprecationWarningHasBeenEmitted = false;
var stackTraceLength = 10;
var config;

// see
// https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode /
// https://github.com/nodejs/node/pull/26599
var unhandledRejectionsMode = 'warn/default';
for (var i = 0; i < process.execArgv.length; i++) {
  if (process.execArgv[i] === '--unhandled-rejections=none') {
    unhandledRejectionsMode = 'none';
github instana / nodejs-sensor / packages / collector / src / announceCycle / agentready.js View on Github external
'use strict';

var clone = require('@instana/core').util.clone;
var compression = require('@instana/core').util.compression;
var tracing = require('@instana/core').tracing;

var metrics = require('../metrics');
var uncaught = require('../uncaught');

var logger;
logger = require('../logger').getLogger('announceCycle/agentready', function(newLogger) {
  logger = newLogger;
});
var requestHandler = require('../agent/requestHandler');
var agentConnection = require('../agentConnection');

var ctx;

var resendFullDataEveryXTransmissions = 300; /* about every 5 minutes */
github instana / nodejs-sensor / packages / collector / src / announceCycle / agentready.js View on Github external
'use strict';

var clone = require('@instana/core').util.clone;
var compression = require('@instana/core').util.compression;
var tracing = require('@instana/core').tracing;

var metrics = require('../metrics');
var uncaught = require('../uncaught');

var logger;
logger = require('../logger').getLogger('announceCycle/agentready', function(newLogger) {
  logger = newLogger;
});
var requestHandler = require('../agent/requestHandler');
var agentConnection = require('../agentConnection');

var ctx;

var resendFullDataEveryXTransmissions = 300; /* about every 5 minutes */

var transmissionsSinceLastFullDataEmit = 0;
github instana / nodejs-sensor / packages / collector / src / uncaught / index.js View on Github external
'use strict';

var serializeError = require('serialize-error');

var logger;
logger = require('../logger').getLogger('util/uncaughtExceptionHandler', function(newLogger) {
  logger = newLogger;
});

var instanaNodeJsCore = require('@instana/core');
var tracing = instanaNodeJsCore.tracing;
var spanBuffer = tracing.spanBuffer;
var stackTraceUtil = instanaNodeJsCore.util.stackTrace;

var downstreamConnection = null;
var processIdentityProvider = null;
var uncaughtExceptionEventName = 'uncaughtException';
var unhandledRejectionEventName = 'unhandledRejection';
var unhandledRejectionDeprecationWarningHasBeenEmitted = false;
var stackTraceLength = 10;
var config;

// see
// https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode /
// https://github.com/nodejs/node/pull/26599
var unhandledRejectionsMode = 'warn/default';
for (var i = 0; i < process.execArgv.length; i++) {