Skip to content

Commit 5d10cdb

Browse files
authored
ref(vue): use startInactiveSpan in tracing mixin (#10406)
ref #10100 Cannot get rid of transactions completely because we rely on accessing the root span to mutate.
1 parent c981524 commit 5d10cdb

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

packages/vue/src/tracing.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getCurrentScope } from '@sentry/browser';
1+
import { getActiveSpan, getCurrentScope, startInactiveSpan } from '@sentry/browser';
22
import type { Span, Transaction } from '@sentry/types';
33
import { logger, timestampInSeconds } from '@sentry/utils';
44

@@ -78,14 +78,12 @@ export const createTracingMixins = (options: TracingOptions): Mixins => {
7878
const isRoot = this.$root === this;
7979

8080
if (isRoot) {
81-
// eslint-disable-next-line deprecation/deprecation
82-
const activeTransaction = getActiveTransaction();
83-
if (activeTransaction) {
81+
const activeSpan = getActiveSpan();
82+
if (activeSpan) {
8483
this.$_sentryRootSpan =
8584
this.$_sentryRootSpan ||
86-
// eslint-disable-next-line deprecation/deprecation
87-
activeTransaction.startChild({
88-
description: 'Application Render',
85+
startInactiveSpan({
86+
name: 'Application Render',
8987
op: `${VUE_OP}.render`,
9088
origin: 'auto.ui.vue',
9189
});
@@ -108,9 +106,8 @@ export const createTracingMixins = (options: TracingOptions): Mixins => {
108106
// Start a new span if current hook is a 'before' hook.
109107
// Otherwise, retrieve the current span and finish it.
110108
if (internalHook == internalHooks[0]) {
111-
// eslint-disable-next-line deprecation/deprecation
112-
const activeTransaction = (this.$root && this.$root.$_sentryRootSpan) || getActiveTransaction();
113-
if (activeTransaction) {
109+
const activeSpan = (this.$root && this.$root.$_sentryRootSpan) || getActiveSpan();
110+
if (activeSpan) {
114111
// Cancel old span for this hook operation in case it didn't get cleaned up. We're not actually sure if it
115112
// will ever be the case that cleanup hooks re not called, but we had users report that spans didn't get
116113
// finished so we finish the span before starting a new one, just to be sure.
@@ -119,9 +116,8 @@ export const createTracingMixins = (options: TracingOptions): Mixins => {
119116
oldSpan.end();
120117
}
121118

122-
// eslint-disable-next-line deprecation/deprecation
123-
this.$_sentrySpans[operation] = activeTransaction.startChild({
124-
description: `Vue <${name}>`,
119+
this.$_sentrySpans[operation] = startInactiveSpan({
120+
name: `Vue <${name}>`,
125121
op: `${VUE_OP}.${operation}`,
126122
origin: 'auto.ui.vue',
127123
});

0 commit comments

Comments
 (0)