Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
fix(tracer.js): propagate tracer to send function (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranrib authored Jan 26, 2021
1 parent dbb71e3 commit ba6ff5a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,15 @@ function addLabelsToTrace() {
* handled
* @param {function} traceSender: The function to use to send the trace. Gets the trace object
* as a parameter and sends a JSON version of it to epsagon's infrastructure
* @param {object} tracerObject Optional tracer object to use for sending.
* @return {*} traceSender's result
*/
function sendCurrentTrace(traceSender) {
const tracerObj = module.exports.getTrace();
function sendCurrentTrace(traceSender, tracerObject) {
const tracerObj = tracerObject || module.exports.getTrace();

const { sendOnlyErrors, ignoredKeys, removeIgnoredKeys } = config.getConfig();
if (!tracerObj) {
utils.debugLog('Trace object not found for sending');
return Promise.resolve();
}
addLabelsToTrace();
Expand Down Expand Up @@ -590,9 +592,9 @@ module.exports.sendTrace = function sendTrace(runnerUpdateFunc, tracerObject) {
// Setting runner's duration.
runnerUpdateFunc();
if (config.getConfig().sendBatch) {
return sendCurrentTrace(traceObject => traceQueue.push(traceObject));
return sendCurrentTrace(traceObject => traceQueue.push(traceObject), tracerObj);
}
return sendCurrentTrace(traceObject => module.exports.postTrace(traceObject));
return sendCurrentTrace(traceObject => module.exports.postTrace(traceObject), tracerObj);
});
};

Expand Down

0 comments on commit ba6ff5a

Please sign in to comment.