Title: NextJS Pages API Route traces are not continued from incoming trace · Issue #14787 · getsentry/sentry-javascript · GitHub
Open Graph Title: NextJS Pages API Route traces are not continued from incoming trace · Issue #14787 · getsentry/sentry-javascript
X Title: NextJS Pages API Route traces are not continued from incoming trace · Issue #14787 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/14787
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"NextJS Pages API Route traces are not continued from incoming trace","articleBody":"### Is there an existing issue for this?\n\n- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [x] I have reviewed the documentation https://docs.sentry.io/\n- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Which SDK are you using?\n\n@sentry/nextjs\n\n### SDK Version\n\n8.46.0\n\n### Framework Version\n\nNextJS 15.1.1\n\n### Link to Sentry event\n\nN/A\n\n### Reproduction Example/SDK Setup\n\nClone my repro: https://github.com/Lms24/nextjs-trace-envelope-header\n\n\n\n### Steps to Reproduce\n\nTo reproduce:\n\n1. `npm install`\n2. `npm run build && npm run start`\n3. `sh req.sh`\n\nObserve that trace_id, sample_rate and transaction fields (+others) are not continued from incoming trace (see `req.sh`). Meaning, it seems like the NextJS SDK starts a new trace for the server-side instead of continuing the passed trace via the headers. \n\n### Expected Result\n\n* The SDK continues the incoming trace, freezes the DSC values passed in via `baggage` \n* When sending its transaction event, the SDK puts the frozen DSC values into the `trace` envelope header and sends the continued trace data in `event.context.trace`\n\n### Actual Result\n\n* The SDK doesn't continue the incoming trace but seems to start a new trace \n* When sending its transaction event, SDK populates the DSC from the new trace and sends the new trace\n\n### Additional information\n\nThe logs suggest that there might be 2 ongoing root spans which possibly(?) conflict with each other?\n\n```\nSentry Logger [log]: [Tracing] Inheriting remote parent's sampled decision for GET /api/test: true\nSentry Logger [log]: [Tracing] Starting sampled root span\n op: \u003c unknown op >\n name: GET /api/test\n ID: 6d6d1a6095cd996c\n parent ID: 9a124d0d6c081115\nSentry Logger [log]: [Tracing] Inheriting parent's sampled decision for executing api route (pages) /api/test: true\nSentry Logger [log]: [Tracing] Starting sampled span\n op: \u003c unknown op >\n name: executing api route (pages) /api/test\n ID: 134e7d6841094ac1\n parent ID: 6d6d1a6095cd996c\n root ID: 6d6d1a6095cd996c\n root description: GET /api/test\nSentry Logger [info]: Starting a new trace with id 1f225918b9444512867b7f0fed977fa5\nSentry Logger [log]: [Tracing] Starting sampled root span\n op: http.server\n name: GET /api/test\n ID: dfd3fc2e5a4b4818\nSentry Logger [log]: [Tracing] Finishing \"http.server\" root span \"GET /api/test\" with ID dfd3fc2e5a4b4818\nSentry Logger [log]: Flushing events...\nSentry Logger [log]: SpanExporter exported 1 spans, 0 spans are waiting for their parent spans to finish\nSentry Logger [log]: Flushing outcomes...\nSentry Logger [log]: No outcomes to send\nSentry Logger [log]: [Tracing] Finishing \"\u003c unknown op >\" span \"executing api route (pages) /api/test\" with ID 134e7d6841094ac1\nSentry Logger [log]: [Tracing] Finishing \"\u003c unknown op >\" root span \"GET /api/test\" with ID 6d6d1a6095cd996c\nSentry Logger [log]: SpanExporter exported 2 spans, 0 spans are waiting for their parent spans to finish\nevent trace context: {\n span_id: 'dfd3fc2e5a4b4818',\n trace_id: '2f656955b869439a0f839731c22cc4eb',\n data: {\n 'sentry.source': 'route',\n 'sentry.sample_rate': 0.99,\n 'sentry.op': 'http.server',\n 'sentry.origin': 'auto.http.nextjs',\n 'http.response.status_code': 200\n },\n origin: 'auto.http.nextjs',\n op: 'http.server',\n status: 'ok'\n}\n{\n envelopeTraceHeader: {\n environment: 'production',\n release: '0UzErXa-sfDtF-53wmU7x',\n public_key: 'c64221a14c2b788162c7b81c2f94d65e',\n trace_id: '2f656955b869439a0f839731c22cc4eb',\n sample_rate: '0.99',\n transaction: 'GET /api/test',\n sampled: 'true'\n }\n}\nSentry Logger [log]: Event processor \"NextLowQualityTransactionsFilter\" dropped event\nSentry Logger [log]: Recording outcome: \"event_processor:transaction\"\nSentry Logger [log]: An event processor returned `null`, will not send event.\nSentry Logger [log]: Done flushing events\n```","author":{"url":"https://github.com/Lms24","@type":"Person","name":"Lms24"},"datePublished":"2024-12-18T17:04:22Z","url":"https://github.com/getsentry/sentry-javascript/issues/14787"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:19aca9f6-e2ee-4fd1-6c48-f3794379e313 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CBB6:43FF1:2BC8482:38795CC:6B0406F1 |
| html-safe-nonce | 62ed7d1f07dad2b694d410eb53ad00ef20f4b37985ede40c7992e5d41dfc65e1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQkI2OjQzRkYxOjJCQzg0ODI6Mzg3OTVDQzo2QjA0MDZGMSIsInZpc2l0b3JfaWQiOiI3NDUyODExNTI5Mzg2NDYwOTEzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8ca873d4fc89a831dcc2edb87906104c123da3aad5a70d0cd20ea13a2901f786 |
| hovercard-subject-tag | issue:2748335859 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/14787/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fdd69e686231d85519a552d1140ec2823b2429cf54fc2dce79e50aa356fde4be/getsentry/sentry-javascript/issues/14787 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fdd69e686231d85519a552d1140ec2823b2429cf54fc2dce79e50aa356fde4be/getsentry/sentry-javascript/issues/14787 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Lms24 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width