-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a custom
httpIntegration
for Remix.
- Loading branch information
1 parent
be79801
commit 06a185e
Showing
10 changed files
with
108 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// This integration is ported from the Next.JS SDK. | ||
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http'; | ||
import { httpIntegration as originalHttpIntegration } from '@sentry/node'; | ||
import type { IntegrationFn } from '@sentry/types'; | ||
|
||
class RemixHttpIntegration extends HttpInstrumentation { | ||
// Instead of the default behavior, we just don't do any wrapping for incoming requests | ||
protected _getPatchIncomingRequestFunction(_component: 'http' | 'https') { | ||
return ( | ||
original: (event: string, ...args: unknown[]) => boolean, | ||
): ((this: unknown, event: string, ...args: unknown[]) => boolean) => { | ||
return function incomingRequest(this: unknown, event: string, ...args: unknown[]): boolean { | ||
return original.apply(this, [event, ...args]); | ||
}; | ||
}; | ||
} | ||
} | ||
|
||
interface HttpOptions { | ||
/** | ||
* Whether breadcrumbs should be recorded for requests. | ||
* Defaults to true | ||
*/ | ||
breadcrumbs?: boolean; | ||
|
||
/** | ||
* Do not capture spans or breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`. | ||
* This controls both span & breadcrumb creation - spans will be non recording if tracing is disabled. | ||
*/ | ||
ignoreOutgoingRequests?: (url: string) => boolean; | ||
} | ||
|
||
/** | ||
* The http integration instruments Node's internal http and https modules. | ||
* It creates breadcrumbs and spans for outgoing HTTP requests which will be attached to the currently active span. | ||
*/ | ||
export const httpIntegration = ((options: HttpOptions = {}) => { | ||
return originalHttpIntegration({ | ||
...options, | ||
_instrumentation: RemixHttpIntegration, | ||
}); | ||
}) satisfies IntegrationFn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters