Skip to content

Commit

Permalink
feat: use NETWORK_TIME timer in request
Browse files Browse the repository at this point in the history
  • Loading branch information
maxjeffos committed Nov 2, 2020
1 parent 1db5492 commit 27fd89f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/request/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import request = require('./request');
import alerts = require('../alerts');
import { MetricsCollector } from '../metrics';

// A hybrid async function: both returns a promise and takes a callback
export = async (
payload: any,
callback?: (err: Error | null, res?, body?) => void,
) => {
const totalNetworkTimeTimer = MetricsCollector.NETWORK_TIME.createInstance();
totalNetworkTimeTimer.start();
try {
const result = await request(payload);
if (result.body.alerts) {
Expand All @@ -21,5 +24,7 @@ export = async (
return callback(error);
}
throw error;
} finally {
totalNetworkTimeTimer.stop();
}
};

0 comments on commit 27fd89f

Please sign in to comment.