Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
}
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();
});
}
'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;
'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;
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;
}
});
};
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;
}
});
};
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;
}
});
};