wsgi.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. }: {
  11. dsn?: string;
  12. } = {}): LayoutProps['steps'] => [
  13. {
  14. type: StepType.INSTALL,
  15. description: (
  16. <Fragment>
  17. <p>
  18. {tct(
  19. '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.',
  20. {
  21. link: (
  22. <ExternalLink href="https://docs.sentry.io/platforms/python/#web-frameworks" />
  23. ),
  24. }
  25. )}
  26. </p>
  27. {t(
  28. '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.'
  29. )}
  30. </Fragment>
  31. ),
  32. configurations: [
  33. {
  34. language: 'python',
  35. code: `
  36. import sentry_sdk
  37. from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
  38. from myapp import wsgi_app
  39. sentry_sdk.init(
  40. dsn="${dsn}",
  41. # Set traces_sample_rate to 1.0 to capture 100%
  42. # of transactions for performance monitoring.
  43. # We recommend adjusting this value in production,
  44. traces_sample_rate=1.0,
  45. )
  46. wsgi_app = SentryWsgiMiddleware(wsgi_app)
  47. `,
  48. },
  49. ],
  50. },
  51. ];
  52. // Configuration End
  53. export function GettingStartedWithWSGI({dsn, ...props}: ModuleProps) {
  54. return <Layout steps={steps({dsn})} {...props} />;
  55. }
  56. export default GettingStartedWithWSGI;