Skip to content

Commit

Permalink
ref(apm): Simplify Tracing._addOffsetToSpan (#2477)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhcarvalho authored Mar 9, 2020
1 parent 0bc7a4d commit f8e8dc8
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions packages/apm/src/integrations/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export class Tracing implements Integration {
);

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

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

Expand Down Expand Up @@ -594,7 +588,7 @@ export class Tracing implements Integration {
const hub = _getCurrentHub();
if (hub) {
const span = hub.startSpan(spanContext);
Tracing._addOffsetToSpan(`${name}${Tracing._currentIndex}`, span as SpanClass);
Tracing._addOffsetToSpan(span as SpanClass);
Tracing._activities[Tracing._currentIndex] = {
name,
span,
Expand Down

0 comments on commit f8e8dc8

Please sign in to comment.