Skip to content

Commit d0fe277

Browse files
authored
fix: transmitted span immediately after receiving response (#2284)
1 parent 05b5b0e commit d0fe277

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

packages/core/src/tracing/instrumentation/databases/couchbase.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,15 @@ function instrumentTransactions(cluster, connectionStr) {
426426

427427
const result = originalFn.apply(this, arguments);
428428

429-
if (result.then && result.catch && result.finally) {
429+
if (result.then && result.catch) {
430430
result
431+
.then(() => {
432+
span.d = Date.now() - span.ts;
433+
span.transmit();
434+
})
431435
.catch(err => {
432436
span.ec = 1;
433437
tracingUtil.setErrorDetails(span, err, 'couchbase');
434-
})
435-
.finally(() => {
436438
span.d = Date.now() - span.ts;
437439
span.transmit();
438440
});
@@ -493,13 +495,13 @@ function instrumentOperation({ connectionStr, bucketName, getBucketTypeFn, sql,
493495
resultHandler(span, result);
494496
}
495497

498+
span.d = Date.now() - span.ts;
499+
span.transmit();
496500
return result;
497501
})
498502
.catch(err => {
499503
span.ec = 1;
500504
tracingUtil.setErrorDetails(span, err, 'couchbase');
501-
})
502-
.finally(() => {
503505
span.d = Date.now() - span.ts;
504506
span.transmit();
505507
});

packages/core/src/tracing/instrumentation/messaging/bull.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,16 @@ function instrumentedProcessJob(ctx, originalProcessJob, originalArgs) {
261261
return promise
262262
.then(data => {
263263
finishSpan(job.failedReason, data, span);
264+
// Make sure the instana foreigner data is removed.
265+
delete options.X_INSTANA_L;
264266
return data;
265267
})
266268
.catch(err => {
267269
addErrorToSpan(err, span);
268270
finishSpan(null, null, span);
269-
throw err;
270-
})
271-
.finally(() => {
272271
// Make sure the instana foreigner data is removed.
273272
delete options.X_INSTANA_L;
273+
throw err;
274274
});
275275
});
276276
}

0 commit comments

Comments
 (0)