in packages/core/lib/context_utils.js [176:205]
setContextMissingStrategy: function setContextMissingStrategy(strategy) {
if (!contextOverride) {
if (typeof strategy === 'string') {
var lookupStrategy = contextUtils.CONTEXT_MISSING_STRATEGY[strategy.toUpperCase()];
if (lookupStrategy) {
contextUtils.contextMissingStrategy.contextMissing = lookupStrategy.contextMissing;
if (process.env.AWS_XRAY_CONTEXT_MISSING) {
logger.getLogger().debug('AWS_XRAY_CONTEXT_MISSING is set. Configured context missing strategy to ' +
process.env.AWS_XRAY_CONTEXT_MISSING + '.');
} else {
logger.getLogger().debug('Configured context missing strategy to: ' + strategy);
}
} else {
throw new Error('Invalid context missing strategy: ' + strategy + '. Valid values are ' +
Object.keys(contextUtils.CONTEXT_MISSING_STRATEGY) + '.');
}
} else if (typeof strategy === 'function') {
contextUtils.contextMissingStrategy.contextMissing = strategy;
logger.getLogger().info('Configured custom context missing strategy to function: ' + strategy.name);
} else {
throw new Error('Context missing strategy must be either a string or a custom function.');
}
} else {
logger.getLogger().warn('Ignoring call to setContextMissingStrategy as AWS_XRAY_CONTEXT_MISSING is set. ' +
'The current context missing strategy will not be changed.');
}
}