How to use @instana/serverless - 7 common examples

To help you get started, we’ve selected a few @instana/serverless 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 / 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
entrySpan.error = entrySpan.ec > 0;
    entrySpan.d = Date.now() - entrySpan.ts;

    entrySpan.transmit();
  }

  const spans = spanBuffer.getAndResetSpans();

  const metricsData = metrics.gatherData();

  const metricsPayload = {
    plugins: [{ name: 'com.instana.plugin.aws.lambda', entityId: identityProvider.getEntityId(), data: metricsData }]
  };

  backendConnector.sendBundle({ spans, metrics: metricsPayload }, err => {
    if (err) {
      // We intentionally do not propagate the error from the backend request - the customer's lambda needs to finish
      // successfully, no matter if we have been able to report metrics and spans.
      logger.warn('Could not send traces and metrics to Instana.', err.message);
      logger.debug('Could not send traces and metrics to Instana.', err);
    } else {
      logger.info('Traces and metrics have been sent to Instana.');
    }
    callback();
  });
}
github instana / nodejs-sensor / packages / aws-lambda / src / index.js View on Github external
'use strict';

const { environment: environmentUtil } = require('@instana/serverless');

environmentUtil.validate();

if (environmentUtil.isValid()) {
  module.exports = exports = require('./wrapper');
} else {
  module.exports = exports = require('./noop_wrapper');
}

// required for backwards compatibility
exports.awsLambda = module.exports;
github instana / nodejs-sensor / packages / aws-lambda / src / index.js View on Github external
'use strict';

const { environment: environmentUtil } = require('@instana/serverless');

environmentUtil.validate();

if (environmentUtil.isValid()) {
  module.exports = exports = require('./wrapper');
} else {
  module.exports = exports = require('./noop_wrapper');
}

// required for backwards compatibility
exports.awsLambda = module.exports;
github instana / nodejs-sensor / packages / aws-lambda / src / metrics / npmPackageVersion.js View on Github external
coreUtil.applicationUnderMonitoring.getMainPackageJson(rootDir.root, (err, pckg) => {
    if (err) {
      logger.warn('Failed to determine main package json. Reason: ', err.message, err.stack);
    }

    if (!err && pckg) {
      exports.currentPayload = pckg.version;
    }
  });
};
github instana / nodejs-sensor / packages / aws-lambda / src / metrics / npmPackageName.js View on Github external
coreUtil.applicationUnderMonitoring.getMainPackageJson(rootDir.root, (err, pckg) => {
    if (err) {
      logger.warn('Failed to determine main package json. Reason: ', err.message, err.stack);
    }

    if (!err && pckg) {
      exports.currentPayload = pckg.name;
    }
  });
};
github instana / nodejs-sensor / packages / aws-lambda / src / metrics / npmPackageDescription.js View on Github external
coreUtil.applicationUnderMonitoring.getMainPackageJson(rootDir.root, (err, pckg) => {
    if (err) {
      logger.warn('Failed to determine main package json. Reason: ', err.message, err.stack);
    }

    if (!err && pckg) {
      exports.currentPayload = pckg.description;
    }
  });
};

@instana/serverless

Internal utility package for serverless Node.js tracing and monitoring with Instana

MIT
Latest version published 6 days ago

Package Health Score

84 / 100
Full package analysis