Skip to content

ref(vue): use startInactiveSpan in tracing mixin #10406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2024
Merged
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
22 changes: 9 additions & 13 deletions packages/vue/src/tracing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCurrentScope } from '@sentry/browser';
import { getActiveSpan, getCurrentScope, startInactiveSpan } from '@sentry/browser';
import type { Span, Transaction } from '@sentry/types';
import { logger, timestampInSeconds } from '@sentry/utils';

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

if (isRoot) {
// eslint-disable-next-line deprecation/deprecation
const activeTransaction = getActiveTransaction();
if (activeTransaction) {
const activeSpan = getActiveSpan();
if (activeSpan) {
this.$_sentryRootSpan =
this.$_sentryRootSpan ||
// eslint-disable-next-line deprecation/deprecation
activeTransaction.startChild({
description: 'Application Render',
startInactiveSpan({
name: 'Application Render',
op: `${VUE_OP}.render`,
origin: 'auto.ui.vue',
});
Expand All @@ -108,9 +106,8 @@ export const createTracingMixins = (options: TracingOptions): Mixins => {
// Start a new span if current hook is a 'before' hook.
// Otherwise, retrieve the current span and finish it.
if (internalHook == internalHooks[0]) {
// eslint-disable-next-line deprecation/deprecation
const activeTransaction = (this.$root && this.$root.$_sentryRootSpan) || getActiveTransaction();
if (activeTransaction) {
const activeSpan = (this.$root && this.$root.$_sentryRootSpan) || getActiveSpan();
if (activeSpan) {
// Cancel old span for this hook operation in case it didn't get cleaned up. We're not actually sure if it
// will ever be the case that cleanup hooks re not called, but we had users report that spans didn't get
// finished so we finish the span before starting a new one, just to be sure.
Expand All @@ -119,9 +116,8 @@ export const createTracingMixins = (options: TracingOptions): Mixins => {
oldSpan.end();
}

// eslint-disable-next-line deprecation/deprecation
this.$_sentrySpans[operation] = activeTransaction.startChild({
description: `Vue <${name}>`,
this.$_sentrySpans[operation] = startInactiveSpan({
name: `Vue <${name}>`,
op: `${VUE_OP}.${operation}`,
origin: 'auto.ui.vue',
});
Expand Down