Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ let logger;

let isActive = false;

const technology = 'sqs';

exports.init = function init(config) {
logger = config.logger;

Expand Down Expand Up @@ -392,7 +394,8 @@ function finishSpan(err, data, span) {
function addErrorToSpan(err, span) {
if (err) {
span.ec = 1;
span.data.sqs.error = err.message || err.code || JSON.stringify(err);
const errorDetails = err.message || err.code || JSON.stringify(err);
span.data[technology].error = errorDetails;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const shimmer = require('../../../../shimmer');
const hook = require('../../../../../util/hook');
const cls = require('../../../../cls');

const technology = 'sqs';

function init() {
hook.onModuleLoad('sqs-consumer', instrument);
}
Expand All @@ -30,7 +32,8 @@ function instrument(SQSConsumer) {
})
.catch(err => {
span.ec = 1;
span.data.sqs.error = err.message || err.code || JSON.stringify(err);
const errorDetails = err.message || err.code || JSON.stringify(err);
span.data[technology].error = errorDetails;
span.d = Date.now() - span.ts;
span.transmitManual();
});
Expand Down Expand Up @@ -62,7 +65,8 @@ function instrument(SQSConsumer) {
})
.catch(err => {
span.ec = 1;
span.data.sqs.error = err.message || err.code || JSON.stringify(err);
const errorDetails = err.message || err.code || JSON.stringify(err);
span.data[technology].error = errorDetails;
span.d = Date.now() - span.ts;
span.transmitManual();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ let isActive = false;

exports.spanName = 'azstorage';

const technology = exports.spanName;

exports.init = function init() {
// Starting from v12.28.0, the package has been migrated to ESM.
// To support ESM-based applications, we now utilize the IITM hook.
Expand Down Expand Up @@ -105,7 +107,8 @@ function instrumentingOperation({
function finishSpan(error, span) {
if (error) {
span.ec = 1;
span.data.azstorage.error = tracingUtil.getErrorDetails(error);
const errorDetails = tracingUtil.getErrorDetails(error);
span.data[technology].error = errorDetails;
}
span.d = Date.now() - span.ts;
span.transmit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const subscriptionRegex = /^projects\/([^/]+)\/subscriptions\/(.+)$/;
let logger;
let isActive = false;

const technology = 'gcps';

exports.init = function init(config) {
logger = config.logger;

Expand Down Expand Up @@ -255,9 +257,11 @@ function addErrorToSpan(err, span) {
if (err) {
span.ec = 1;
if (err.message) {
span.data.gcps.error = err.message;
const errorDetails = err.message;
span.data[technology].error = errorDetails;
} else if (typeof err === 'string') {
span.data.gcps.error = err;
const errorDetails = err;
span.data[technology].error = errorDetails;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const hook = require('../../../../util/hook');
const tracingUtil = require('../../../tracingUtil');

let isActive = false;
const technology = 'gcs';

exports.init = function init() {
hook.onModuleLoad('@google-cloud/storage', instrument);
Expand Down Expand Up @@ -458,7 +459,8 @@ function instrumentedCreateStream(operation, bindEvent, finalEvent, ctx, origina
function finishSpan(error, result, span, extractorPost) {
if (error) {
span.ec = 1;
span.data.gcs.error = tracingUtil.getErrorDetails(error);
const errorDetails = tracingUtil.getErrorDetails(error);
span.data[technology].error = errorDetails;
}

if (extractorPost) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ let isActive = false;
const bucketLookup = {};

exports.spanName = 'couchbase';
const technology = exports.spanName;

exports.activate = function activate() {
isActive = true;
Expand Down Expand Up @@ -430,7 +431,8 @@ function instrumentTransactions(cluster, connectionStr) {
result
.catch(err => {
span.ec = 1;
span.data.couchbase.error = tracingUtil.getErrorDetails(err);
const errorDetails = tracingUtil.getErrorDetails(err);
span.data[technology].error = errorDetails;
})
.finally(() => {
span.d = Date.now() - span.ts;
Expand Down Expand Up @@ -497,7 +499,8 @@ function instrumentOperation({ connectionStr, bucketName, getBucketTypeFn, sql,
})
.catch(err => {
span.ec = 1;
span.data.couchbase.error = tracingUtil.getErrorDetails(err);
const errorDetails = tracingUtil.getErrorDetails(err);
span.data[technology].error = errorDetails;
})
.finally(() => {
span.d = Date.now() - span.ts;
Expand All @@ -510,7 +513,8 @@ function instrumentOperation({ connectionStr, bucketName, getBucketTypeFn, sql,
originalArgs[callbackIndex] = cls.ns.bind(function instanaCallback(err, result) {
if (err) {
span.ec = 1;
span.data.couchbase.error = tracingUtil.getErrorDetails(err);
const errorDetails = tracingUtil.getErrorDetails(err);
span.data[technology].error = errorDetails;
}

if (resultHandler) {
Expand Down
48 changes: 33 additions & 15 deletions packages/core/src/tracing/instrumentation/databases/db2.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const cls = require('../../cls');

let isActive = false;

const technology = 'db2';

const CLOSE_TIMEOUT_IN_MS = process.env.DB2_CLOSE_TIMEOUT_IN_MS || 1000 * 30;

exports.spanName = 'ibmdb2';
Expand Down Expand Up @@ -222,7 +224,8 @@ function captureFetchError(result, span) {
argsFetch[fetchIndex] = function instanaFetchCb(fetchCbErr) {
if (fetchCbErr) {
span.ec = 1;
span.data.db2.error = tracingUtil.getErrorDetails(fetchCbErr);
const errorDetails = tracingUtil.getErrorDetails(fetchCbErr);
span.data[technology].error = errorDetails;
}

return fetchCb.apply(this, arguments);
Expand All @@ -232,7 +235,9 @@ function captureFetchError(result, span) {
return originalFn.apply(this, arguments);
} catch (caughtErr) {
span.ec = 1;
span.data.db2.error = tracingUtil.getErrorDetails(caughtErr);
const errorDetails = tracingUtil.getErrorDetails(caughtErr);

span.data[technology].error = errorDetails;
throw caughtErr;
}
};
Expand All @@ -249,12 +254,14 @@ function captureFetchError(result, span) {

if (res instanceof Error) {
span.ec = 1;
span.data.db2.error = tracingUtil.getErrorDetails(res);
const errorDetails = tracingUtil.getErrorDetails(res);
span.data[technology].error = errorDetails;
}
return res;
} catch (err) {
span.ec = 1;
span.data.db2.error = tracingUtil.getErrorDetails(err);
const errorDetails = tracingUtil.getErrorDetails(err);
span.data[technology].error = errorDetails;

return err;
}
Expand All @@ -278,14 +285,16 @@ function instrumentQueryHelper(ctx, originalArgs, originalFunction, stmt, isAsyn

if (result instanceof Error) {
span.ec = 1;
span.data.db2.error = tracingUtil.getErrorDetails(result);
const errorDetails = tracingUtil.getErrorDetails(result);
span.data[technology].error = errorDetails;
}

finishSpan(ctx, result, span);
return result;
} catch (e) {
span.ec = 1;
span.data.db2.error = tracingUtil.getErrorDetails(e);
const errorDetails = tracingUtil.getErrorDetails(e);
span.data[technology].error = errorDetails;
finishSpan(ctx, null, span);
throw e;
}
Expand All @@ -304,7 +313,8 @@ function instrumentQueryHelper(ctx, originalArgs, originalFunction, stmt, isAsyn
originalArgs[customerCallbackIndex] = function instanaCallback(err) {
if (err) {
span.ec = 1;
span.data.db2.error = tracingUtil.getErrorDetails(err);
const errorDetails = tracingUtil.getErrorDetails(err);
span.data[technology].error = errorDetails;
}

finishSpan(ctx, null, span);
Expand All @@ -324,7 +334,8 @@ function instrumentQueryHelper(ctx, originalArgs, originalFunction, stmt, isAsyn
})
.catch(err => {
span.ec = 1;
span.data.db2.error = tracingUtil.getErrorDetails(err);
const errorDetails = tracingUtil.getErrorDetails(err);
span.data[technology].error = errorDetails;
finishSpan(ctx, null, span);
return err;
});
Expand Down Expand Up @@ -394,7 +405,8 @@ function instrumentExecuteHelper(ctx, originalArgs, stmtObject, prepareCallParen
return result;
} catch (err) {
span.ec = 1;
span.data.db2.error = tracingUtil.getErrorDetails(err);
const errorDetails = tracingUtil.getErrorDetails(err);
span.data[technology].error = errorDetails;
finishSpan(ctx, null, span);
return err;
}
Expand Down Expand Up @@ -441,7 +453,8 @@ function instrumentExecuteHelper(ctx, originalArgs, stmtObject, prepareCallParen
args[origCallbackIndex] = function instanaExecuteCallback(executeErr, result) {
if (executeErr) {
span.ec = 1;
span.data.db2.error = tracingUtil.getErrorDetails(executeErr);
const errorDetails = tracingUtil.getErrorDetails(executeErr);
span.data[technology].error = errorDetails;
finishSpan(ctx, null, span);
return origCallback.apply(this, arguments);
}
Expand Down Expand Up @@ -470,7 +483,8 @@ function instrumentQueryResultHelper(ctx, originalArgs, originalFunction, stmt,
return result;
} catch (err) {
span.ec = 1;
span.data.db2.error = tracingUtil.getErrorDetails(err);
const errorDetails = tracingUtil.getErrorDetails(err);
span.data[technology].error = errorDetails;
finishSpan(ctx, null, span);
return err;
}
Expand All @@ -489,7 +503,8 @@ function instrumentQueryResultHelper(ctx, originalArgs, originalFunction, stmt,
originalArgs[customerCallbackIndex] = function instanaCallback(err) {
if (err) {
span.ec = 1;
span.data.db2.error = tracingUtil.getErrorDetails(err);
const errorDetails = tracingUtil.getErrorDetails(err);
span.data[technology].error = errorDetails;
}

const result = customerCallback.apply(this, arguments);
Expand Down Expand Up @@ -550,7 +565,8 @@ function finishSpan(ctx, result, span) {
if (!closeSyncCalled) {
closeSyncCalled = true;
span.ec = 1;
span.data.db2.error = `'result.closeSync' was not called within ${CLOSE_TIMEOUT_IN_MS}ms.`;
const errorDetails = `'result.closeSync' was not called within ${CLOSE_TIMEOUT_IN_MS}ms.`;
span.data[technology].error = errorDetails;
span.d = Date.now() - span.ts;
span.transmit();
}
Expand Down Expand Up @@ -578,7 +594,8 @@ function handleTransaction(ctx, span) {
arguments[1] = function instanaOnEndOverride(onEndErr) {
if (onEndErr) {
span.ec = 1;
span.data.db2.error = tracingUtil.getErrorDetails(onEndErr) || 'Error not available.';
const errorDetails = tracingUtil.getErrorDetails(onEndErr) || 'Error not available.';
span.data[technology].error = errorDetails;
}

span.d = Date.now() - span.ts;
Expand All @@ -597,7 +614,8 @@ function handleTransaction(ctx, span) {
return result;
} catch (err) {
span.ec = 1;
span.data.db2.error = tracingUtil.getErrorDetails(err) || 'Error not available.';
const errorDetails = tracingUtil.getErrorDetails(err) || 'Error not available.';
span.data[technology].error = errorDetails;
span.transmit();
throw err;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ let isActive = false;

exports.spanName = 'elasticsearch';
exports.batchable = true;
const technology = exports.spanName;

exports.init = function init(config) {
logger = config.logger;
Expand Down Expand Up @@ -200,7 +201,8 @@ function onError(span, error) {
span.d = Date.now() - span.ts;
span.ec = 1;
if (error) {
span.data.elasticsearch.error = tracingUtil.getErrorDetails(error);
const errorDetails = tracingUtil.getErrorDetails(error);
span.data[technology].error = errorDetails;
}
if (error.meta && error.meta.meta) {
getConnectionDetailsFromResultMeta(span, error.meta);
Expand Down
13 changes: 9 additions & 4 deletions packages/core/src/tracing/instrumentation/databases/ioredis.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ let isActive = false;

exports.spanName = 'redis';
exports.batchable = true;
const technology = exports.spanName;

exports.activate = function activate() {
isActive = true;
Expand Down Expand Up @@ -115,7 +116,8 @@ function instrumentSendCommand(original) {

if (error) {
span.ec = 1;
span.data.redis.error = error.message;
const errorDetails = error.message;
span.data[technology].error = errorDetails;
}

span.transmit();
Expand Down Expand Up @@ -221,7 +223,8 @@ function multiCommandEndCallback(clsContextForMultiOrPipeline, span, error) {

if (error) {
span.ec = commandCount;
span.data.redis.error = error.message;
const errorDetails = error.message;
span.data[technology].error = errorDetails;
}

span.transmit();
Expand All @@ -241,7 +244,8 @@ function pipelineCommandEndCallback(clsContextForMultiOrPipeline, span, error, r
if (error) {
// ioredis docs mention that this should never be possible, but better be safe than sorry
span.ec = commandCount;
span.data.redis.error = tracingUtil.getErrorDetails(error);
const errorDetails = tracingUtil.getErrorDetails(error);
span.data[technology].error = errorDetails;
} else {
let numberOfErrors = 0;
let sampledError;
Expand All @@ -257,7 +261,8 @@ function pipelineCommandEndCallback(clsContextForMultiOrPipeline, span, error, r

if (numberOfErrors > 0) {
span.ec = numberOfErrors;
span.data.redis.error = tracingUtil.getErrorDetails(sampledError);
const errorDetails = tracingUtil.getErrorDetails(sampledError);
span.data[technology].error = errorDetails;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const commands = [
exports.spanName = 'mongo';
exports.batchable = true;

const technology = exports.spanName;

exports.init = function init() {
// unified topology layer
hook.onFileLoad(/\/mongodb\/lib\/cmap\/connection\.js/, instrumentCmapConnection);
Expand Down Expand Up @@ -438,7 +440,8 @@ function createWrappedCallback(span, originalCallback) {
return cls.ns.bind(function (error) {
if (error) {
span.ec = 1;
span.data.mongo.error = tracingUtil.getErrorDetails(error);
const errorDetails = tracingUtil.getErrorDetails(error);
span.data[technology].error = errorDetails;
}

span.d = Date.now() - span.ts;
Expand Down Expand Up @@ -466,7 +469,8 @@ function handleCallbackOrPromise(ctx, originalArgs, originalFunction, span) {
})
.catch(err => {
span.ec = 1;
span.data.mongo.error = tracingUtil.getErrorDetails(err);
const errorDetails = tracingUtil.getErrorDetails(err);
span.data[technology].error = errorDetails;
span.d = Date.now() - span.ts;
span.transmit();
return err;
Expand Down
Loading