Skip to content

Commit 8e9f76d

Browse files
authored
Merge pull request #287 from sam-github/lrtime-optional
Do not export lrtime if it is not implemented
2 parents b669015 + 228742b commit 8e9f76d

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,7 @@ module.exports.monitor = function() {
241241
return this.api;
242242
};
243243

244-
module.exports.lrtime = function() {
245-
return agent.lrtime();
246-
};
244+
module.exports.lrtime = agent.lrtime;
247245

248246
module.exports.configure = function(options) {
249247
options = options || {};
@@ -262,4 +260,4 @@ module.exports.setJSONProfilingMode = function(val) {
262260

263261
module.exports.getJSONProfilingMode = function() {
264262
return jsonProfilingMode;
265-
}
263+
}

tests/api_tests.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,22 @@ var monitor = app.appmetrics.monitor();
1919
app.appmetrics.enable("profiling");
2020

2121
var tap = require('tap');
22-
tap.plan(5); // NOTE: This needs to be updated when tests are added/removed
22+
tap.plan(6); // NOTE: This needs to be updated when tests are added/removed
2323
tap.tearDown(function(){
2424
app.endRun();
2525
});
2626

27+
tap.test('lrtime is a function or undefined', function(t) {
28+
var lrtime = app.appmetrics.lrtime;
29+
30+
if (lrtime) {
31+
t.doesNotThrow(lrtime, 'callable, not just present');
32+
} else {
33+
t.notEqual(process.platform, 'linux', 'lrtime mandatory on linux');
34+
}
35+
t.end();
36+
});
37+
2738
var completedTests = {}; //Stores which tests have been run, ensures single run per test
2839

2940
monitor.on('cpu', function(data) {
@@ -394,4 +405,4 @@ function runEventLoopTests(elData, t){
394405
t.ok(elData.latency[elem] <= 5000,
395406
"Contains " + elem + " latency value less that 5 seconds");
396407
}
397-
}
408+
}

0 commit comments

Comments
 (0)