Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
<template>
<p>{{ $route.params.param }} - {{ $route.params.param }}</p>

<ErrorButton id="errorBtn" errorText="Error thrown from Param Route Button" />
<button @click="fetchData">Fetch Server Data</button>
</template>

<script setup lang="ts">
import { useRoute, useFetch } from '#imports'

const route = useRoute();
const param = route.params.param;

const fetchData = async () => {
const fetchError = async () => {
await useFetch(`/api/param-error/${param}`);
}

const fetchData = async () => {
await useFetch(`/api/test-param/${param}`);
};
</script>

<template>
<p>Param: {{ $route.params.param }}</p>

<ErrorButton id="errorBtn" errorText="Error thrown from Param Route Button" />
<button @click="fetchData">Fetch Server Data</button>
<button @click="fetchError">Fetch Server Error</button>
</template>

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { expect, test } from '@playwright/test';
import { waitForTransaction } from '@sentry-internal/test-utils';

test.describe('distributed tracing', () => {
const PARAM = 's0me-param';

test('capture a distributed pageload trace', async ({ page }) => {
const clientTxnEventPromise = waitForTransaction('nuxt-3', txnEvent => {
return txnEvent.transaction === '/test-param/:param()';
});

const serverTxnEventPromise = waitForTransaction('nuxt-3', txnEvent => {
return txnEvent.transaction.includes('GET /test-param/');
});

const [_, clientTxnEvent, serverTxnEvent] = await Promise.all([
page.goto(`/test-param/${PARAM}`),
clientTxnEventPromise,
serverTxnEventPromise,
expect(page.getByText(`Param: ${PARAM}`)).toBeVisible(),
]);

expect(clientTxnEvent).toMatchObject({
transaction: '/test-param/:param()',
transaction_info: { source: 'route' },
type: 'transaction',
contexts: {
trace: {
op: 'pageload',
origin: 'auto.pageload.vue',
},
},
});

expect(serverTxnEvent).toMatchObject({
transaction: 'GET /test-param/s0me-param', // todo: parametrize (nitro)
transaction_info: { source: 'url' },
type: 'transaction',
contexts: {
trace: {
op: 'http.server',
origin: 'auto.http.otel.http',
},
},
});

// connected trace
expect(clientTxnEvent.contexts?.trace?.trace_id).toBe(serverTxnEvent.contexts?.trace?.trace_id);
expect(clientTxnEvent.contexts?.trace?.parent_span_id).toBe(serverTxnEvent.contexts?.trace?.span_id);
});
});
Loading