tornado.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
  3. import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  4. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  5. import {ProductSolution} from 'sentry/components/onboarding/productSelection';
  6. import {t, tct} from 'sentry/locale';
  7. // Configuration Start
  8. const profilingConfiguration = ` # Set profiles_sample_rate to 1.0 to profile 100%
  9. # of sampled transactions.
  10. # We recommend adjusting this value in production.
  11. profiles_sample_rate=1.0,`;
  12. const performanceConfiguration = ` # Set traces_sample_rate to 1.0 to capture 100%
  13. # of transactions for performance monitoring.
  14. # We recommend adjusting this value in production.
  15. traces_sample_rate=1.0,`;
  16. const introduction = (
  17. <p>
  18. {tct(
  19. 'The Tornado integration adds support for the [link:Tornado Web Framework]. A Tornado version of 5 or greater and Python 3.6 or greater is required.',
  20. {
  21. link: <ExternalLink href="https://www.tornadoweb.org/en/stable/" />,
  22. }
  23. )}
  24. </p>
  25. );
  26. export const steps = ({
  27. sentryInitContent,
  28. }: {
  29. sentryInitContent: string;
  30. }): LayoutProps['steps'] => [
  31. {
  32. type: StepType.INSTALL,
  33. description: <p>{tct('Install [code:sentry-sdk] from PyPI:', {code: <code />})}</p>,
  34. configurations: [
  35. {
  36. language: 'bash',
  37. code: '$ pip install --upgrade sentry-sdk',
  38. },
  39. {
  40. description: (
  41. <p>
  42. {tct(
  43. "If you're on Python 3.6, you also need the [code:aiocontextvars] package:",
  44. {
  45. code: <code />,
  46. }
  47. )}
  48. </p>
  49. ),
  50. language: 'bash',
  51. code: '$ pip install --upgrade aiocontextvars',
  52. },
  53. ],
  54. },
  55. {
  56. type: StepType.CONFIGURE,
  57. description: t('Initialize the SDK before starting the server:'),
  58. configurations: [
  59. {
  60. language: 'python',
  61. code: `
  62. import sentry_sdk
  63. from sentry_sdk.integrations.tornado import TornadoIntegration
  64. sentry_sdk.init(
  65. ${sentryInitContent}
  66. )
  67. # Your app code here, without changes
  68. class MyHandler(...):
  69. ...
  70. `,
  71. },
  72. ],
  73. },
  74. ];
  75. // Configuration End
  76. export function GettingStartedWithTornado({
  77. dsn,
  78. activeProductSelection = [],
  79. ...props
  80. }: ModuleProps) {
  81. const otherConfigs: string[] = [];
  82. let sentryInitContent: string[] = [
  83. ` dsn="${dsn}",`,
  84. ` integrations=[TornadoIntegration()],`,
  85. ];
  86. if (activeProductSelection.includes(ProductSolution.PERFORMANCE_MONITORING)) {
  87. otherConfigs.push(performanceConfiguration);
  88. }
  89. if (activeProductSelection.includes(ProductSolution.PROFILING)) {
  90. otherConfigs.push(profilingConfiguration);
  91. }
  92. sentryInitContent = sentryInitContent.concat(otherConfigs);
  93. return (
  94. <Layout
  95. introduction={introduction}
  96. steps={steps({
  97. sentryInitContent: sentryInitContent.join('\n'),
  98. })}
  99. {...props}
  100. />
  101. );
  102. }
  103. export default GettingStartedWithTornado;