Skip to content

Commit f8e8dc8

Browse files
authored
ref(apm): Simplify Tracing._addOffsetToSpan (getsentry#2477)
1 parent 0bc7a4d commit f8e8dc8

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

packages/apm/src/integrations/tracing.ts

+4-10
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ export class Tracing implements Integration {
322322
);
323323

324324
Tracing._activeTransaction = span;
325-
Tracing._addOffsetToSpan(`idleTransactionStarted-${Tracing._currentIndex}`, span as SpanClass);
325+
Tracing._addOffsetToSpan(span as SpanClass);
326326

327327
// We need to do this workaround here and not use configureScope
328328
// Reason being at the time we start the inital transaction we do not have a client bound on the hub yet
@@ -543,15 +543,9 @@ export class Tracing implements Integration {
543543
* @param measureName name of the performance measure
544544
* @param span Span to add data.offset to
545545
*/
546-
private static _addOffsetToSpan(measureName: string, span: SpanClass): void {
546+
private static _addOffsetToSpan(span: SpanClass): void {
547547
if (global.performance) {
548-
const name = `#sentry-${measureName}`;
549-
performance.measure(name);
550-
const measure = performance.getEntriesByName(name).pop();
551-
if (measure) {
552-
span.setData('offset', Tracing._msToSec(measure.duration));
553-
}
554-
performance.clearMeasures(name);
548+
span.setData('offset', Tracing._msToSec(performance.now()));
555549
}
556550
}
557551

@@ -594,7 +588,7 @@ export class Tracing implements Integration {
594588
const hub = _getCurrentHub();
595589
if (hub) {
596590
const span = hub.startSpan(spanContext);
597-
Tracing._addOffsetToSpan(`${name}${Tracing._currentIndex}`, span as SpanClass);
591+
Tracing._addOffsetToSpan(span as SpanClass);
598592
Tracing._activities[Tracing._currentIndex] = {
599593
name,
600594
span,

0 commit comments

Comments
 (0)