|
1 | 1 | import {
|
| 2 | + SEMANTIC_ATTRIBUTE_SENTRY_OP, |
2 | 3 | SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
|
3 | 4 | applySdkMetadata,
|
4 | 5 | getClient,
|
@@ -189,6 +190,7 @@ export function init(options: NodeOptions): NodeClient | undefined {
|
189 | 190 | // with patterns (e.g. http.server spans) that will produce confusing data.
|
190 | 191 | if (spanAttributes?.['next.span_type'] !== undefined) {
|
191 | 192 | span.setAttribute('sentry.skip_span_data_inference', true);
|
| 193 | + span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto'); |
192 | 194 | }
|
193 | 195 |
|
194 | 196 | // We want to rename these spans because they look like "GET /path/to/route" and we already emit spans that look
|
@@ -286,6 +288,28 @@ export function init(options: NodeOptions): NodeClient | undefined {
|
286 | 288 | ),
|
287 | 289 | );
|
288 | 290 |
|
| 291 | + getGlobalScope().addEventProcessor( |
| 292 | + Object.assign( |
| 293 | + (event => { |
| 294 | + // Sometimes, the HTTP integration will not work, causing us not to properly set an op for spans generated by |
| 295 | + // Next.js that are actually more or less correct server HTTP spans, so we are backfilling the op here. |
| 296 | + if ( |
| 297 | + event.type === 'transaction' && |
| 298 | + event.transaction?.match(/^(RSC )?GET /) && |
| 299 | + event.contexts?.trace?.data?.['sentry.rsc'] === true && |
| 300 | + !event.contexts.trace.op |
| 301 | + ) { |
| 302 | + event.contexts.trace.data = event.contexts.trace.data || {}; |
| 303 | + event.contexts.trace.data[SEMANTIC_ATTRIBUTE_SENTRY_OP] = 'http.server'; |
| 304 | + event.contexts.trace.op = 'http.server'; |
| 305 | + } |
| 306 | + |
| 307 | + return event; |
| 308 | + }) satisfies EventProcessor, |
| 309 | + { id: 'NextjsTransactionEnhancer' }, |
| 310 | + ), |
| 311 | + ); |
| 312 | + |
289 | 313 | if (process.env.NODE_ENV === 'development') {
|
290 | 314 | getGlobalScope().addEventProcessor(devErrorSymbolicationEventProcessor);
|
291 | 315 | }
|
|
0 commit comments