diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-static/app/metrics/page.tsx b/dev-packages/e2e-tests/test-applications/nextjs-16-static/app/metrics/page.tsx index fdb7bc0a40a7..07f37bac197f 100644 --- a/dev-packages/e2e-tests/test-applications/nextjs-16-static/app/metrics/page.tsx +++ b/dev-packages/e2e-tests/test-applications/nextjs-16-static/app/metrics/page.tsx @@ -4,23 +4,26 @@ import * as Sentry from '@sentry/nextjs'; export default function Page() { const handleClick = async () => { - Sentry.metrics.count('test.page.count', 1, { - attributes: { - page: '/metrics', - 'random.attribute': 'Apples', - }, - }); - Sentry.metrics.distribution('test.page.distribution', 100, { - attributes: { - page: '/metrics', - 'random.attribute': 'Manzanas', - }, - }); - Sentry.metrics.gauge('test.page.gauge', 200, { - attributes: { - page: '/metrics', - 'random.attribute': 'Mele', - }, + // Emit inside a span so `span_id` doesn't depend on whether the pageload span is still active. + Sentry.startSpan({ name: 'emit-metrics' }, () => { + Sentry.metrics.count('test.page.count', 1, { + attributes: { + page: '/metrics', + 'random.attribute': 'Apples', + }, + }); + Sentry.metrics.distribution('test.page.distribution', 100, { + attributes: { + page: '/metrics', + 'random.attribute': 'Manzanas', + }, + }); + Sentry.metrics.gauge('test.page.gauge', 200, { + attributes: { + page: '/metrics', + 'random.attribute': 'Mele', + }, + }); }); await fetch('/metrics/route-handler'); }; diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16/app/metrics/page.tsx b/dev-packages/e2e-tests/test-applications/nextjs-16/app/metrics/page.tsx index fdb7bc0a40a7..07f37bac197f 100644 --- a/dev-packages/e2e-tests/test-applications/nextjs-16/app/metrics/page.tsx +++ b/dev-packages/e2e-tests/test-applications/nextjs-16/app/metrics/page.tsx @@ -4,23 +4,26 @@ import * as Sentry from '@sentry/nextjs'; export default function Page() { const handleClick = async () => { - Sentry.metrics.count('test.page.count', 1, { - attributes: { - page: '/metrics', - 'random.attribute': 'Apples', - }, - }); - Sentry.metrics.distribution('test.page.distribution', 100, { - attributes: { - page: '/metrics', - 'random.attribute': 'Manzanas', - }, - }); - Sentry.metrics.gauge('test.page.gauge', 200, { - attributes: { - page: '/metrics', - 'random.attribute': 'Mele', - }, + // Emit inside a span so `span_id` doesn't depend on whether the pageload span is still active. + Sentry.startSpan({ name: 'emit-metrics' }, () => { + Sentry.metrics.count('test.page.count', 1, { + attributes: { + page: '/metrics', + 'random.attribute': 'Apples', + }, + }); + Sentry.metrics.distribution('test.page.distribution', 100, { + attributes: { + page: '/metrics', + 'random.attribute': 'Manzanas', + }, + }); + Sentry.metrics.gauge('test.page.gauge', 200, { + attributes: { + page: '/metrics', + 'random.attribute': 'Mele', + }, + }); }); await fetch('/metrics/route-handler'); };