wsgi.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import {Fragment} from 'react';
  2. import ExternalLink from 'sentry/components/links/externalLink';
  3. import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
  4. import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  5. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  6. import {t, tct} from 'sentry/locale';
  7. // Configuration Start
  8. export const steps = ({
  9. dsn,
  10. }: Partial<Pick<ModuleProps, 'dsn'>> = {}): LayoutProps['steps'] => [
  11. {
  12. type: StepType.INSTALL,
  13. description: (
  14. <Fragment>
  15. <p>
  16. {tct(
  17. 'It is recommended to use an [link:integration for your particular WSGI framework if available], as those are easier to use and capture more useful information.',
  18. {
  19. link: (
  20. <ExternalLink href="https://docs.sentry.io/platforms/python/#web-frameworks" />
  21. ),
  22. }
  23. )}
  24. </p>
  25. {t(
  26. 'If you use a WSGI framework not directly supported by the SDK, or wrote a raw WSGI app, you can use this generic WSGI middleware. It captures errors and attaches a basic amount of information for incoming requests.'
  27. )}
  28. </Fragment>
  29. ),
  30. configurations: [
  31. {
  32. language: 'python',
  33. code: `
  34. import sentry_sdk
  35. from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
  36. from myapp import wsgi_app
  37. sentry_sdk.init(
  38. dsn="${dsn}",
  39. # Set traces_sample_rate to 1.0 to capture 100%
  40. # of transactions for performance monitoring.
  41. # We recommend adjusting this value in production,
  42. traces_sample_rate=1.0,
  43. )
  44. wsgi_app = SentryWsgiMiddleware(wsgi_app)
  45. `,
  46. },
  47. ],
  48. },
  49. ];
  50. // Configuration End
  51. export function GettingStartedWithWSGI({dsn, ...props}: ModuleProps) {
  52. return <Layout steps={steps({dsn})} {...props} />;
  53. }
  54. export default GettingStartedWithWSGI;