Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
globalStats.record([{
measure: mLineLengths,
value: processedLine.length
}], tags);
globalStats.record([{
measure: mLatencyMs,
value: sinceInMilliseconds(endNanoseconds, startNanoseconds)
}], tags);
} catch (err) {
console.log(err);
const errTags = new TagMap();
errTags.set(methodKey, { value: 'repl' });
errTags.set(statusKey, { value: 'ERROR' });
globalStats.record([{
measure: mLatencyMs,
value: sinceInMilliseconds(endNanoseconds, startNanoseconds)
}], errTags);
}
// Restarts the start time for the REPL
startNanoseconds = endNanoseconds;
});
globalStats.record([{
measure: mLineLengths,
value: processedLine.length
}], tags);
globalStats.record([{
measure: mLatencyMs,
value: sinceInMilliseconds(endNanoseconds, startNanoseconds)
}], tags);
} catch (err) {
console.log(err);
const errTags = new TagMap();
errTags.set(methodKey, { value: 'repl' });
errTags.set(statusKey, { value: 'ERROR' });
globalStats.record([{
measure: mLatencyMs,
value: sinceInMilliseconds(endNanoseconds, startNanoseconds)
}], errTags);
}
// Restarts the start time for the REPL
startNanoseconds = endNanoseconds;
});
const processedLine = processLine(line); // Evaluate
console.log(processedLine); // Print
// Registers the end of our REPL
[_, endNanoseconds] = process.hrtime();
const tags = new TagMap();
tags.set(methodKey, { value: 'REPL' });
tags.set(statusKey, { value: 'OK' });
globalStats.record([{
measure: mLineLengths,
value: processedLine.length
}], tags);
globalStats.record([{
measure: mLatencyMs,
value: sinceInMilliseconds(endNanoseconds, startNanoseconds)
}], tags);
} catch (err) {
console.log(err);
const errTags = new TagMap();
errTags.set(methodKey, { value: 'repl' });
errTags.set(statusKey, { value: 'ERROR' });
globalStats.record([{
measure: mLatencyMs,
value: sinceInMilliseconds(endNanoseconds, startNanoseconds)
}], errTags);
}
// Restarts the start time for the REPL
tags.set(tagPhase, { value: valueTLSNegotiation });
globalStats.record([{
measure: mLatencyMs,
value: 1
}], tags);
tags.set(tagPhase, { value: valueLoad });
globalStats.record([{
measure: mLatencyMs,
value: 1
}], tags);
const tags1 = new TagMap();
tags1.set(tagClient, { value: valueWeb });
globalStats.record([{
measure: mClickCount,
value: 1
}], tags1);
res.status(200).send("Received").end();
console.log('Competed recording metrics');
} catch (err) {
console.log(`Could not save stats: ${err}`);
res.status(500).send("Error saving stats").end();
}
// [END web_client_monitoring_record]
});
lineReader.on('line', function (line) {
// Read
try {
const processedLine = processLine(line); // Evaluate
console.log(processedLine); // Print
// Registers the end of our REPL
[_, endNanoseconds] = process.hrtime();
const tags = new TagMap();
tags.set(methodKey, { value: 'REPL' });
tags.set(statusKey, { value: 'OK' });
globalStats.record([{
measure: mLineLengths,
value: processedLine.length
}], tags);
globalStats.record([{
measure: mLatencyMs,
value: sinceInMilliseconds(endNanoseconds, startNanoseconds)
}], tags);
} catch (err) {
console.log(err);
const errTags = new TagMap();
errTags.set(methodKey, { value: 'repl' });
errTags.set(statusKey, { value: 'ERROR' });
globalStats.record([{
measure: mLatencyMs,
const valueDNSLookup = "dns_lookup";
const valueLoad = "load";
const valueWeb = "web";
const tags = new TagMap();
tags.set(tagPhase, { value: valueDNSLookup });
tags.set(tagClient, { value: valueWeb });
// [START web_client_monitoring_record]
try {
globalStats.record([{
measure: mLatencyMs,
value: 1
}], tags);
tags.set(tagPhase, { value: valueTLSNegotiation });
globalStats.record([{
measure: mLatencyMs,
value: 1
}], tags);
tags.set(tagPhase, { value: valueLoad });
globalStats.record([{
measure: mLatencyMs,
value: 1
}], tags);
const tags1 = new TagMap();
tags1.set(tagClient, { value: valueWeb });
globalStats.record([{
measure: mClickCount,
value: 1
}], tags1);
globalStats.withTagContext(tags2, () => {
console.log('Enter Scope 2');
printMap('Add Tags', tags2.tags);
printMap('Current Tags == Default + tags1 + tags2:', globalStats.getCurrentTagContext().tags);
const measurement = { measure: mLatencyMs, value: 10 };
globalStats.record([measurement]);
console.log('Close Scope 2');
});
printMap('Current Tags == Default + tags1:', globalStats.getCurrentTagContext().tags);