Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
+ nodeEnvData['appmetrics.version'] + ", expected 99.99.99.123456789012 (or 99.99.99-dev.99.12345678901)");
}
if (nodeEnvData['agentcore.version'])
{
assert(/^\d+\.\d+\.\d+\.\d{12}$/.test(nodeEnvData['agentcore.version']),
"Agent core version format not recognised"
+ nodeEnvData['agentcore.version'] + ", expected 99.99.99.123456789012");
}
// NOTE(mjt): heap.size.limit, max.semi.space.size and max.old.space.size were added in
// appmetrics 1.0.4 (required field in this version onwards)
// NOTE(ignasbol): max.heap.size included as well as part of 1.0.4
var prefix = 'Node environment message ';
if (nodeEnvData['heap.size.limit']) {
assert(isInteger(nodeEnvData['heap.size.limit']),
prefix + 'does not have an integer heap size limit (' + nodeEnvData['heap.size.limit'] + ')');
assert(parseInt(nodeEnvData['heap.size.limit']) > 0,
prefix + 'does not have a positive heap size limit (' + nodeEnvData['heap.size.limit'] + ')');
assert(isInteger(nodeEnvData['max.semi.space.size']),
prefix + 'does not have an integer max semi space size (' + nodeEnvData['max.semi.space.size'] + ')');
assert(parseInt(nodeEnvData['max.semi.space.size']) > 0,
prefix + 'does not have a positive max semi space size (' + nodeEnvData['max.semi.space.size'] + ')');
assert(isInteger(nodeEnvData['max.old.space.size']),
prefix + 'does not have an integer max old space size (' + nodeEnvData['max.old.space.size'] + ')');
assert(parseInt(nodeEnvData['max.old.space.size']) > 0,
prefix + 'does not have a positive max old space size (' + nodeEnvData['max.old.space.size'] + ')');
assert(4*parseInt(nodeEnvData['max.semi.space.size']) + parseInt(nodeEnvData['max.old.space.size']) === parseInt(nodeEnvData['heap.size.limit']),
prefix + 'values for max old space size and max semi space size do not match heap size limit');
"Appmetrics version format not recognised"
+ nodeEnvData['appmetrics.version'] + ", expected 99.99.99.123456789012 (or 99.99.99-dev.99.12345678901)");
}
if (nodeEnvData['agentcore.version'])
{
assert(/^\d+\.\d+\.\d+\.\d{12}$/.test(nodeEnvData['agentcore.version']),
"Agent core version format not recognised"
+ nodeEnvData['agentcore.version'] + ", expected 99.99.99.123456789012");
}
// NOTE(mjt): heap.size.limit, max.semi.space.size and max.old.space.size were added in
// appmetrics 1.0.4 (required field in this version onwards)
// NOTE(ignasbol): max.heap.size included as well as part of 1.0.4
var prefix = 'Node environment message ';
if (nodeEnvData['heap.size.limit']) {
assert(isInteger(nodeEnvData['heap.size.limit']),
prefix + 'does not have an integer heap size limit (' + nodeEnvData['heap.size.limit'] + ')');
assert(parseInt(nodeEnvData['heap.size.limit']) > 0,
prefix + 'does not have a positive heap size limit (' + nodeEnvData['heap.size.limit'] + ')');
assert(isInteger(nodeEnvData['max.semi.space.size']),
prefix + 'does not have an integer max semi space size (' + nodeEnvData['max.semi.space.size'] + ')');
assert(parseInt(nodeEnvData['max.semi.space.size']) > 0,
prefix + 'does not have a positive max semi space size (' + nodeEnvData['max.semi.space.size'] + ')');
assert(isInteger(nodeEnvData['max.old.space.size']),
prefix + 'does not have an integer max old space size (' + nodeEnvData['max.old.space.size'] + ')');
assert(parseInt(nodeEnvData['max.old.space.size']) > 0,
prefix + 'does not have a positive max old space size (' + nodeEnvData['max.old.space.size'] + ')');
assert(4*parseInt(nodeEnvData['max.semi.space.size']) + parseInt(nodeEnvData['max.old.space.size']) === parseInt(nodeEnvData['heap.size.limit']),
nodeEnvData['agentcore.version'],
/^\d+\.\d+\.\d+\.\d{12}$/,
"Agent core version matches '99.99.99.123456789012' format"
);
}
// NOTE(mjt): heap.size.limit, max.semi.space.size and max.old.space.size were added in
// appmetrics 1.0.4 (required field in this version onwards)
// NOTE(ignasbol): max.heap.size included as well as part of 1.0.4
if (nodeEnvData['heap.size.limit']) {
t.ok(
isInteger(nodeEnvData['heap.size.limit']),
'heap.size.limit is an integer (value was: ' + nodeEnvData['heap.size.limit'] + ')'
);
t.ok(parseInt(nodeEnvData['heap.size.limit']) > 0, 'heap.size.limit is positive');
t.ok(
isInteger(nodeEnvData['max.semi.space.size']),
'max.semi.space.size is an integer (value was: ' + nodeEnvData['max.semi.space.size'] + ')'
);
t.ok(parseInt(nodeEnvData['max.semi.space.size']) > 0, 'max.semi.size is positive');
t.ok(
isInteger(nodeEnvData['max.old.space.size']),
'max.old.space.size is an integer (value was: ' + nodeEnvData['max.old.space.size'] + ')'
);
t.ok(parseInt(nodeEnvData['max.old.space.size']) > 0, 'max.old.space.size is positive');
if (semver.gt(process.version, '12.0.0')) {
t.skip();
} else if (semver.gt(process.version, '10.0.0')) {
// heap size limit is now scaled by a factor - see
"Appmetrics version matches '99.99.99(-dev).123456789012' format"
);
}
if (nodeEnvData['agentcore.version']) {
t.match(
nodeEnvData['agentcore.version'],
/^\d+\.\d+\.\d+\.\d{12}$/,
"Agent core version matches '99.99.99.123456789012' format"
);
}
// NOTE(mjt): heap.size.limit, max.semi.space.size and max.old.space.size were added in
// appmetrics 1.0.4 (required field in this version onwards)
// NOTE(ignasbol): max.heap.size included as well as part of 1.0.4
if (nodeEnvData['heap.size.limit']) {
t.ok(
isInteger(nodeEnvData['heap.size.limit']),
'heap.size.limit is an integer (value was: ' + nodeEnvData['heap.size.limit'] + ')'
);
t.ok(parseInt(nodeEnvData['heap.size.limit']) > 0, 'heap.size.limit is positive');
t.ok(
isInteger(nodeEnvData['max.semi.space.size']),
'max.semi.space.size is an integer (value was: ' + nodeEnvData['max.semi.space.size'] + ')'
);
t.ok(parseInt(nodeEnvData['max.semi.space.size']) > 0, 'max.semi.size is positive');
t.ok(
isInteger(nodeEnvData['max.old.space.size']),
'max.old.space.size is an integer (value was: ' + nodeEnvData['max.old.space.size'] + ')'
);
if (nodeEnvData['agentcore.version']) {
t.match(
nodeEnvData['agentcore.version'],
/^\d+\.\d+\.\d+\.\d{12}$/,
"Agent core version matches '99.99.99.123456789012' format"
);
}
// NOTE(mjt): heap.size.limit, max.semi.space.size and max.old.space.size were added in
// appmetrics 1.0.4 (required field in this version onwards)
// NOTE(ignasbol): max.heap.size included as well as part of 1.0.4
if (nodeEnvData['heap.size.limit']) {
t.ok(
isInteger(nodeEnvData['heap.size.limit']),
'heap.size.limit is an integer (value was: ' + nodeEnvData['heap.size.limit'] + ')'
);
t.ok(parseInt(nodeEnvData['heap.size.limit']) > 0, 'heap.size.limit is positive');
t.ok(
isInteger(nodeEnvData['max.semi.space.size']),
'max.semi.space.size is an integer (value was: ' + nodeEnvData['max.semi.space.size'] + ')'
);
t.ok(parseInt(nodeEnvData['max.semi.space.size']) > 0, 'max.semi.size is positive');
t.ok(
isInteger(nodeEnvData['max.old.space.size']),
'max.old.space.size is an integer (value was: ' + nodeEnvData['max.old.space.size'] + ')'
);
t.ok(parseInt(nodeEnvData['max.old.space.size']) > 0, 'max.old.space.size is positive');
if (semver.gt(process.version, '12.0.0')) {
}
if (nodeEnvData['agentcore.version']) {
t.match(
nodeEnvData['agentcore.version'],
/^\d+\.\d+\.\d+\.\d{12}$/,
"Agent core version matches '99.99.99.123456789012' format"
);
}
// NOTE(mjt): heap.size.limit, max.semi.space.size and max.old.space.size were added in
// appmetrics 1.0.4 (required field in this version onwards)
// NOTE(ignasbol): max.heap.size included as well as part of 1.0.4
if (nodeEnvData['heap.size.limit']) {
t.ok(
isInteger(nodeEnvData['heap.size.limit']),
'heap.size.limit is an integer (value was: ' + nodeEnvData['heap.size.limit'] + ')'
);
t.ok(parseInt(nodeEnvData['heap.size.limit']) > 0, 'heap.size.limit is positive');
t.ok(
isInteger(nodeEnvData['max.semi.space.size']),
'max.semi.space.size is an integer (value was: ' + nodeEnvData['max.semi.space.size'] + ')'
);
t.ok(parseInt(nodeEnvData['max.semi.space.size']) > 0, 'max.semi.size is positive');
t.ok(
isInteger(nodeEnvData['max.old.space.size']),
'max.old.space.size is an integer (value was: ' + nodeEnvData['max.old.space.size'] + ')'
);
t.ok(parseInt(nodeEnvData['max.old.space.size']) > 0, 'max.old.space.size is positive');
assert(isInteger(nodeEnvData['heap.size.limit']),
prefix + 'does not have an integer heap size limit (' + nodeEnvData['heap.size.limit'] + ')');
assert(parseInt(nodeEnvData['heap.size.limit']) > 0,
prefix + 'does not have a positive heap size limit (' + nodeEnvData['heap.size.limit'] + ')');
assert(isInteger(nodeEnvData['max.semi.space.size']),
prefix + 'does not have an integer max semi space size (' + nodeEnvData['max.semi.space.size'] + ')');
assert(parseInt(nodeEnvData['max.semi.space.size']) > 0,
prefix + 'does not have a positive max semi space size (' + nodeEnvData['max.semi.space.size'] + ')');
assert(isInteger(nodeEnvData['max.old.space.size']),
prefix + 'does not have an integer max old space size (' + nodeEnvData['max.old.space.size'] + ')');
assert(parseInt(nodeEnvData['max.old.space.size']) > 0,
prefix + 'does not have a positive max old space size (' + nodeEnvData['max.old.space.size'] + ')');
assert(4*parseInt(nodeEnvData['max.semi.space.size']) + parseInt(nodeEnvData['max.old.space.size']) === parseInt(nodeEnvData['heap.size.limit']),
prefix + 'values for max old space size and max semi space size do not match heap size limit');
assert(isInteger(nodeEnvData['max.heap.size']),
prefix + 'does not have an integer max heap size ('
+ nodeEnvData['max.heap.size'] + ')');
assert(parseInt(nodeEnvData['max.heap.size']) > 0,
prefix + 'does not have a positive max heap size ('
+ nodeEnvData['max.heap.size'] + ')');
}
var requiredKeys = ['runtime.version', 'runtime.name', 'command.line.arguments'];
requiredKeys.forEach(function(key) {
assert(nodeEnvData.hasOwnProperty(key), "Missing key '" + key + "' in Node environment message");
});