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

Commit

Permalink
feat(tracer): export add to pending event function (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
idonava authored Dec 2, 2020
1 parent 280ff5f commit debb13e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ const session = axios.create({
* @param {Promise} [promise] A promise that resolves when the event handling is Done, if required.
*/
module.exports.addEvent = function addEvent(event, promise) {
const tracerObj = module.exports.getTrace();
if (!tracerObj) {
return;
}
this.addPendingEvent(event, promise);
tracerObj.trace.addEvent(event);
};

/**
* Add promise event result to pendingEvents map.
* @param {proto.event_pb.Event} event The event
* @param {Promise} [promise] A promise that resolves when the event handling is Done
*/
module.exports.addPendingEvent = function addPendingEvent(event, promise) {
const tracerObj = module.exports.getTrace();
if (!tracerObj) {
return;
Expand All @@ -87,8 +101,6 @@ module.exports.addEvent = function addEvent(event, promise) {
}))
);
}

tracerObj.trace.addEvent(event);
};

/**
Expand Down

0 comments on commit debb13e

Please sign in to comment.