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): accept tracer object to send (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranrib authored Jan 24, 2021
1 parent cac92a9 commit 3f4b601
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ module.exports.MAX_LABEL_SIZE = 10 * 1024;

module.exports.MAX_HTTP_VALUE_SIZE = 10 * 1024;

module.exports.MAX_TRACE_SIZE_BYTES = 64 * 1024;
module.exports.MAX_TRACE_SIZE_BYTES = process.env.EPSAGON_MAX_TRACE_SIZE ?
parseInt(process.env.EPSAGON_MAX_TRACE_SIZE, 10) : 64 * 1024;

module.exports.DEFAULT_SAMPLE_RATE = 1;

Expand Down
8 changes: 5 additions & 3 deletions src/events/ioredis.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ function redisClientWrapper(wrappedFunction) {

const responsePromise = new Promise((resolve) => {
command.promise.then((result) => {
eventInterface.addToMetadata(dbapiEvent, {
'redis.response': result,
});
if (result) {
eventInterface.addToMetadata(dbapiEvent, {
'redis.response': result.toString(),
});
}
}).catch((err) => {
eventInterface.setException(dbapiEvent, err);
}).finally(() => {
Expand Down
6 changes: 4 additions & 2 deletions src/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,13 @@ module.exports.postTrace = function postTrace(traceObject) {
/**
* Sends the trace to epsagon's infrastructure when all pending events are finished.
* @param {function} runnerUpdateFunc function that sets the duration of the runner.
* @param {object} tracerObject Optional tracer object to use for sending.
* @returns {Promise} a promise that is resolved when the trace transmission ends.
*/
module.exports.sendTrace = function sendTrace(runnerUpdateFunc) {
const tracerObj = module.exports.getTrace();
module.exports.sendTrace = function sendTrace(runnerUpdateFunc, tracerObject) {
const tracerObj = tracerObject || module.exports.getTrace();
if (!tracerObj || (tracerObj && tracerObj.disabled)) {
utils.debugLog('Trace object not found or disabled');
return Promise.resolve();
}

Expand Down

0 comments on commit 3f4b601

Please sign in to comment.