11import * as diagnosticsChannel from 'node:diagnostics_channel' ;
2- import type { IntegrationFn , Span , SpanAttributes } from '@sentry/core' ;
2+ import type { Span , SpanAttributes } from '@sentry/core' ;
33import {
4- defineIntegration ,
54 getActiveSpan ,
65 isObjectLike ,
76 SEMANTIC_ATTRIBUTE_SENTRY_OP ,
@@ -12,11 +11,8 @@ import {
1211} from '@sentry/core' ;
1312import { bindTracingChannelToSpan } from '@sentry/server-utils' ;
1413import { CODE_FUNCTION , HTTP_METHOD , HTTP_ROUTE , HTTP_STATUS_CODE , HTTP_URL } from '@sentry/conventions/attributes' ;
15- import { getClient } from '@sentry/node' ;
16- import type { RemixOptions } from '../../utils/remixOptions' ;
1714import { remixChannels } from '@sentry/server-utils/orchestrion' ;
1815
19- const INTEGRATION_NAME = 'Remix' as const ;
2016const ORIGIN = 'auto.http.orchestrion.remix' ;
2117
2218const NOOP = ( ) : void => { } ;
@@ -237,43 +233,18 @@ function applyFormDataAttributes(
237233 } ) ;
238234}
239235
240- function instrumentRemix ( actionFormDataAttributes : Record < string , string | boolean > | undefined ) : void {
241- subscribeRequestHandler ( ) ;
242- subscribeMatchServerRoutes ( ) ;
243- subscribeCallRouteLoader ( ) ;
244- // Always instrument actions; `actionFormDataAttributes` only gates the optional form-data
245- // attribute extraction, not whether ACTION spans are created.
246- subscribeCallRouteAction ( actionFormDataAttributes ) ;
247- }
248-
249- const _remixChannelIntegration = ( ( ) => {
250- return {
251- name : INTEGRATION_NAME ,
252- setupOnce ( ) {
253- // `tracingChannel` is unavailable before Node 18.19, so do nothing in that case.
254- if ( ! diagnosticsChannel . tracingChannel ) {
255- return ;
256- }
257-
258- const client = getClient ( ) ;
259- const options = client ?. getOptions ( ) as RemixOptions | undefined ;
260- const actionFormDataAttributes = client ?. getDataCollectionOptions ( ) . httpBodies . includes ( 'incomingRequest' )
261- ? options ?. captureActionFormDataKeys
262- : undefined ;
263-
264- waitForTracingChannelBinding ( ( ) => {
265- instrumentRemix ( actionFormDataAttributes ) ;
266- } ) ;
267- } ,
268- } ;
269- } ) satisfies IntegrationFn ;
236+ export function instrumentRemix ( actionFormDataAttributes : Record < string , string | boolean > | undefined ) : void {
237+ // `tracingChannel` is unavailable before Node 18.19, so do nothing in that case.
238+ if ( ! diagnosticsChannel . tracingChannel ) {
239+ return ;
240+ }
270241
271- /**
272- * Orchestrion-driven Remix integration.
273- *
274- * Ports the vendored `RemixInstrumentation` (an OTel `InstrumentationBase`) to diagnostics-channel
275- * listeners, with orchestrion injecting the channels into `@remix-run/server-runtime`. Creates the
276- * `remix.request` server span plus `LOADER`/`ACTION` spans, and enriches the request span with the
277- * matched route. Requires the orchestrion runtime hook or bundler plugin to be active.
278- */
279- export const remixChannelIntegration = defineIntegration ( _remixChannelIntegration ) ;
242+ waitForTracingChannelBinding ( ( ) => {
243+ subscribeRequestHandler ( ) ;
244+ subscribeMatchServerRoutes ( ) ;
245+ subscribeCallRouteLoader ( ) ;
246+ // Always instrument actions; `actionFormDataAttributes` only gates the optional form-data
247+ // attribute extraction, not whether ACTION spans are created.
248+ subscribeCallRouteAction ( actionFormDataAttributes ) ;
249+ } ) ;
250+ }
0 commit comments